<?php

namespace Tables;

class Fop_mail_host_box_dir_email {
  
  

  
  

    // --- Statische Methoden ---
  
  public static function getDefaults() { 
    
    
    // --- BLOCK: main ---
    
	// erstellt ein leeres Objekt zum Befüllen mit Daten oder als Default fürs Create-Formular
	$data = ['timestamp' => null,
		'senderDisplay' => '',
		'senderEmail' => null,
		'subject' => '',
		'content' => '',
		'directory' => null,
		'seen' => FALSE];
	return $data;
	
    
  }

  public static function deleteConfirmAction($id = null ) { 
    
    // Methodenimplementierung überschrieben.
    throw new \FOP\AccessDeniedException();return false;
  }

  public static function viewAction($id = null ) { 
    
    
    // --- BLOCK: 0_CSRFValidate ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') \FOP\Session::validateCSRFToken(); else \FOP\Session::getCSRFToken();

    // --- BLOCK: 0_CSRF_ensure ---
    
	\FOP\Session::getCSRFToken();
    // --- BLOCK: access ---
    if(!(!\FOP\User::getIsGuest())) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access+validators ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') {
		
		/* Validatoren */
		
		

		
		/* Sanitizer */

		

		
	}
	
    // --- BLOCK: fetch ---
    
	\FOP\I18n::ensureIsLoaded();
	$row = self::view($id);

    // --- BLOCK: main ---
    
		// Main block
	
    // --- BLOCK: main-1 ---
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
		if (!isset($_POST['ok'])) {
			\FOP\Database::beginTransaction();
    // --- BLOCK: main-2:save-clone-prepare ---
    
		$data = self::view($id);
	
    // --- BLOCK: main-2:save-main ---
    /* view */
    // --- BLOCK: main-3 ---
    
			\FOP\Database::commitTransaction();
			
		}
		
		if (isset($_POST['ok'])) {
			
			
			if (isset($_POST['fop-from']) && $_POST['fop-from']) {
				// Redirect zu fop-from
				header('Location: ' . (isset($id) && is_string($id) ? preg_replace('/&insert_param=(.*)$/', '&$1=' . ($id instanceof \FOP\IDList ? $id->toString() : $id), $_POST['fop-from']) : $_POST['fop-from']));
			} else {
				if ($to = (isset($_GET['popup']) ? \FOP\Util::getCurrentBaseurl().'jscloser.php?action=popup' : \FOP\Session::getPayload('dv-fop_mail_host_box_dir_email')['from'] ?? null)) {
					header('Location: ' . $to);
					die();
				}
				if (!\TablesRouter\Fop_mail_host_box_dir_email::indexAccess()) {
					if (!\FOPRouter\Index::indexAccess()) {
						header('Location: ' . \FOPRouter\Index::indexURL2(['popup' => $_GET['popup'] ?? null]));
						die();
					}
					header('Location: ' . \FOPRouter\Index::indexURL2(['popup' => $_GET['popup'] ?? null]));
					die();
				}
				header('Location: ' . \TablesRouter\Fop_mail_host_box_dir_email::indexURL2(['popup' => $_GET['popup'] ?? null]));
			}
			die();
	
		}
		die(json_encode($_POST));
	} else {
    // --- BLOCK: main-4:load-main ---
    
		$data = self::view($id); // TODO: klären, wer die Funktion bereitstellt (momentan crud/view.fop)
	
    // --- BLOCK: main-5 ---
    ?><?php
			header('Content-Type: text/html; charset=UTF-8');
			header('X-XSS-Protection: 1; mode=block');
			header('Strict-Transport-Security: max-age=63072000');
			header('X-Content-Type-Options: nosniff');
			header("Content-Security-Policy: default-src *  data: blob: 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * data: blob: 'unsafe-inline'; font-src * data: blob: 'unsafe-inline';");


		?><!DOCTYPE html><html><head><title><?php echo htmlentities(str_replace('%s', \FOP\Database::query('SELECT CONCAT((SELECT (CONCAT('.qi('CBD4eCc3').'.'.qi('display').', \' <\', '.qi('CBD4eCc3').'.'.qi('address').', \'>\')) FROM '.qi('fop_mail_host_box_dir_email_recipient').' '.qi('CBD4eCc3').' WHERE '.qi('CBD4eCc3').'.'.qi('email').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('ID').' LIMIT 1), \' - \', '.qi('fop_mail_host_box_dir_email').'.'.qi('subject').', \' (\', '.(\FOP\Database::getDriver() == 'mysql' ? 'DATE_FORMAT(FROM_UNIXTIME' : 'to_char(to_timestamp') . '('.qi('fop_mail_host_box_dir_email').'.'.qi('timestamp').')' . ', '.\FOP\Database::sessionVarSQL('datetimeformat').'), \')\') AS description FROM '.qi('fop_mail_host_box_dir_email').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() ?: '', _('%s'))); ?></title><base href='<?php echo \FOP\Util::getCurrentBaseurl(); ?>'><meta name="google" content="notranslate"><meta http-equiv="Content-Language" content="<?php echo htmlentities(\FOP\I18n::getLocale()); ?>"><meta charset="utf-8"><link rel="stylesheet" type="text/css" href="style_dependencies.css?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"><link rel="stylesheet" type="text/css" href="style.css?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"><script type="text/javascript" src="js/script_dependencies.js?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"></script><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="mobile-web-app-capable" content="yes"><link rel="manifest" href="manifest.webmanifest"><script type="text/javascript">moment.locale('<?php echo(\FOP\I18n::getShortLocale()); ?>');</script><script type="text/javascript" src="js/form.js"></script><script type="text/javascript">window.globals = <?php
	echo json_encode(['user:superadmin' => /* TODO: resanitizer später mal */(integer) \FOP\User::getSuperadmin(), 'user:mitglied' => /* TODO: resanitizer später mal */(integer) \FOP\User::getMitglied(), 'user:gruppe' => /* TODO: resanitizer später mal */(integer) \FOP\User::getGruppe(), 'user:campaign' => /* TODO: resanitizer später mal */(integer) \FOP\User::getCampaign(), 'user:sammlung' => /* TODO: resanitizer später mal */(integer) \FOP\User::getSammlung(), 'user:protokoll' => /* TODO: resanitizer später mal */(integer) \FOP\User::getProtokoll(), 'user:ID' => /* TODO: resanitizer später mal */(integer) \FOP\User::getID(), 'user:buchhaltung' => /* TODO: resanitizer später mal */(integer) \FOP\User::getBuchhaltung()]);
?>;</script><script type="text/javascript" src="angular/<?php echo(\FOP\I18n::getShortLocale()); ?>/js/alltypes.js?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"></script><script type="text/javascript" src="angular/angular-i18n/angular-locale_<?php echo \FOP\I18n::getAngularLocale(); ?>.js"></script><script type="text/javascript" src="js/date-filter.js"></script><script type="text/javascript" src="js/dropdown.js"></script><script type="text/javascript" src="js/numeric.js"></script><script type="text/javascript" src="js/getparam.js"></script><script type="text/javascript" src="js/tables.js"></script>
		<script type="text/javascript" src="js/parsehash.js"></script><script type="text/javascript">
		window.query = <?php echo json_encode($_GET, JSON_FORCE_OBJECT); ?>;
		window.baseurl = <?php echo json_encode(\FOP\Util::getCurrentBaseurl()); ?>;

		window.i18n_weiter = <?php echo json_encode(_('Weiter'));?>;
		//Filter I18n:
		window.i18n_quartal = <?php echo json_encode(_('Quarter'));?>;
		window.i18n_alle = <?php echo json_encode(_('All'));?>;
		window.i18n_leere = <?php echo json_encode(_('Empty'));?>;
		window.i18n_tag = <?php echo json_encode(_('Tag'));?>;
		window.i18n_woche = <?php echo json_encode(_('Woche'));?>;
		window.i18n_zeitraum = <?php echo json_encode(_('Period'));?>;
		window.i18n_monat = <?php echo json_encode(_('Monat'));?>;
		window.i18n_jahr = <?php echo json_encode(_('Jahr'));?>;
		window.i18n_von = <?php echo json_encode(_('filters_from'));?>;
		window.i18n_bis = <?php echo json_encode(_('filters_to'));?>;
		window.i18n_tabButton = <?php echo json_encode(_('open_in_new_tab'));?>;
		window.i18n_closeButton = <?php echo json_encode(_('close'));?>;
		</script></head><script type="text/javascript">const fopPushPublicKey = '<?php echo(addslashes(\FOP\Configuration::getFOPPushPublicKey())); ?>';
        const fopUserID = <?php echo(intval(\FOP\User::getID())); ?>;
        var fopPushDisabled = false;
    </script><script type="text/javascript" src="js/serviceworkersetup.js"></script><body ng-app='app'>
		<div class='mdl-js-snackbar mdl-snackbar' id='snackbar'>
			<div class='mdl-snackbar__text'></div>
			<button class='mdl-snackbar__action' type='button'></button>
		</div>
		<script>
			var snackbar = document.querySelector('#snackbar');
			componentHandler.upgradeElement(snackbar, 'MaterialSnackbar');
			$(function () {
				setTimeout(function () {
					$('.fop-layout').scrollTop(0);
				}, 0);
			});
		</script>

		<?php if (isset($_GET['popup'])) { ?>
		<header class="fop-header mdl-layout__header mdl-layout__header mdl-layout__header--scroll">
				<div class="mdl-layout__header-row">
					<?php
	if ($dv = \FOP\Session::getPayload('dv-fop_mail_host_box_dir_email')) { ?>
	<?php if (isset($dv['prev'])) {?><a href="<?php echo htmlentities(str_replace('XXX', urlencode($id), $dv['prev'])); ?>" class="mdl-button mdl-js-button mdl-button--icon">
		<i class="material-icons">keyboard_arrow_left</i>
	</a><?php } ?>
	<a href="<?php echo htmlentities($dv['from']); ?>" class="mdl-button mdl-js-button mdl-button--icon">
		<i class="material-icons">view_list</i>
	</a>
	<?php if (isset($dv['next'])) {?><a href="<?php echo htmlentities(str_replace('XXX', urlencode($id), $dv['next'])); ?>" class="mdl-button mdl-js-button mdl-button--icon">
		<i class="material-icons">keyboard_arrow_right</i>
	</a><?php } ?><?php } ?><span class="mdl-layout-title"><?php echo htmlentities(str_replace('%s', \FOP\Database::query('SELECT CONCAT((SELECT (CONCAT('.qi('CBD4eCc3').'.'.qi('display').', \' <\', '.qi('CBD4eCc3').'.'.qi('address').', \'>\')) FROM '.qi('fop_mail_host_box_dir_email_recipient').' '.qi('CBD4eCc3').' WHERE '.qi('CBD4eCc3').'.'.qi('email').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('ID').' LIMIT 1), \' - \', '.qi('fop_mail_host_box_dir_email').'.'.qi('subject').', \' (\', '.(\FOP\Database::getDriver() == 'mysql' ? 'DATE_FORMAT(FROM_UNIXTIME' : 'to_char(to_timestamp') . '('.qi('fop_mail_host_box_dir_email').'.'.qi('timestamp').')' . ', '.\FOP\Database::sessionVarSQL('datetimeformat').'), \')\') AS description FROM '.qi('fop_mail_host_box_dir_email').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() ?: '', _('%s'))); ?></span><div class="mdl-layout-spacer"></div><span class="noprint mdl-layout-title mdl-layout--large-screen-only"><div class="mdl-textfield mdl-js-textfield"><input id="supersearch" accesskey="f" class="mdl-textfield__input" type="text" onkeydown="if (event.keyCode == 13 && this.value) window.location.href = 'FOP/Index/searchURL?q=' + encodeURIComponent(this.value) + '&from=<?php echo htmlentities(urlencode(\FOP\Util::getBackUrl())); ?>';" value="<?php echo htmlentities($_GET['q'] ?? ''); ?>" style="border-bottom: 1px solid white;"/><label class="mdl-textfield__label" style="color: inherit"><?php echo(_('search')); ?> - <?php
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
			// MAC: Control+ davor
			echo 'Control + ';
		}
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {
			// Firefox
			if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
				// MAC: Control + Alt + key
				echo 'Alt + F';
			} else {
				echo 'Alt + Shift + F';
			}
		} else {
			// Internet Explorer, Chrome, Safari, Opera
			echo 'Alt + F';
		}
	?></label></div></span><i onclick='addFav(null)' class='material-icons fop-favorites' id='favorites_button'>star_border</i>
				</div>
      	</header>
			<style>
				.content {
					margin-top: 0px !important;
				}
			</style>
			<div id='content' class='popup' >
		<?php } else { ?>
			<div class="fop-layout mdl-layout mdl-js-layout mdl-layout--fixed-drawer mdl-layout--fixed-header">
			<header class="fop-header mdl-layout__header mdl-layout__header mdl-layout__header--scroll">
				<div class="mdl-layout__header-row">
					<?php
	if ($dv = \FOP\Session::getPayload('dv-fop_mail_host_box_dir_email')) { ?>
	<?php if (isset($dv['prev'])) {?><a href="<?php echo htmlentities(str_replace('XXX', urlencode($id), $dv['prev'])); ?>" class="mdl-button mdl-js-button mdl-button--icon">
		<i class="material-icons">keyboard_arrow_left</i>
	</a><?php } ?>
	<a href="<?php echo htmlentities($dv['from']); ?>" class="mdl-button mdl-js-button mdl-button--icon">
		<i class="material-icons">view_list</i>
	</a>
	<?php if (isset($dv['next'])) {?><a href="<?php echo htmlentities(str_replace('XXX', urlencode($id), $dv['next'])); ?>" class="mdl-button mdl-js-button mdl-button--icon">
		<i class="material-icons">keyboard_arrow_right</i>
	</a><?php } ?><?php } ?><span class="mdl-layout-title"><?php echo htmlentities(str_replace('%s', \FOP\Database::query('SELECT CONCAT((SELECT (CONCAT('.qi('CBD4eCc3').'.'.qi('display').', \' <\', '.qi('CBD4eCc3').'.'.qi('address').', \'>\')) FROM '.qi('fop_mail_host_box_dir_email_recipient').' '.qi('CBD4eCc3').' WHERE '.qi('CBD4eCc3').'.'.qi('email').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('ID').' LIMIT 1), \' - \', '.qi('fop_mail_host_box_dir_email').'.'.qi('subject').', \' (\', '.(\FOP\Database::getDriver() == 'mysql' ? 'DATE_FORMAT(FROM_UNIXTIME' : 'to_char(to_timestamp') . '('.qi('fop_mail_host_box_dir_email').'.'.qi('timestamp').')' . ', '.\FOP\Database::sessionVarSQL('datetimeformat').'), \')\') AS description FROM '.qi('fop_mail_host_box_dir_email').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() ?: '', _('%s'))); ?></span><div class="mdl-layout-spacer"></div><span class="noprint mdl-layout-title mdl-layout--large-screen-only"><div class="mdl-textfield mdl-js-textfield"><input id="supersearch" accesskey="f" class="mdl-textfield__input" type="text" onkeydown="if (event.keyCode == 13 && this.value) window.location.href = 'FOP/Index/searchURL?q=' + encodeURIComponent(this.value) + '&from=<?php echo htmlentities(urlencode(\FOP\Util::getBackUrl())); ?>';" value="<?php echo htmlentities($_GET['q'] ?? ''); ?>" style="border-bottom: 1px solid white;"/><label class="mdl-textfield__label" style="color: inherit"><?php echo(_('search')); ?> - <?php
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
			// MAC: Control+ davor
			echo 'Control + ';
		}
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {
			// Firefox
			if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
				// MAC: Control + Alt + key
				echo 'Alt + F';
			} else {
				echo 'Alt + Shift + F';
			}
		} else {
			// Internet Explorer, Chrome, Safari, Opera
			echo 'Alt + F';
		}
	?></label></div></span><i onclick='addFav(null)' class='material-icons fop-favorites' id='favorites_button'>star_border</i>
				</div>
      		</header>


				<?php  \EasyEditor\Navigation::render(); ?>
      
				<main class="mdl-layout__content" id="content">
					<div class="fop-content">
						<?php } ?>
						
							<div class="content" id="1">
								

								<form
									
									action="<?php echo \TablesRouter\Fop_mail_host_box_dir_email::viewURL2(['popup' => $_GET['popup'] ?? null, 'id' => $id]); ?>"
									method="post"
									enctype="multipart/form-data" ng-submit='submit($event)'
									onsubmit="
										if (window.running_uploads) {
											event.preventDefault();
											alert('<?php echo htmlentities(json_encode(_('fileUploadStillActive')));?>');
										}
									"
								 
								id="cardform-wf_fop_mail_host_box_dir_email_view"
								style="width: 100%; height: 100%;"
								class='mdl-grid'
									ng-controller="FormWf_fop_mail_host_box_dir_email_view" ng-init="form = <?php echo htmlentities(json_encode([]));
									?>;"
								>
								<?php
								 echo '<input type="hidden" name="csrftoken" value="' . htmlentities(\FOP\Session::getCSRFToken()) . '">';
								 if (isset($_GET['from'])) echo '<input type="hidden" name="fop-from" value="' . htmlentities($_GET['from']) . '">';
								 ?>
								<div id='fop-upbar'></div>
								<?php \DataView\Fop_mail_host_box_dir_email_recipient_email::renderScript($id); ?><?php \DataView\Fop_mail_host_box_dir_email_thread_email::renderScript($id); ?>
									<?php
									$features = [];
									if ((true) && (!\FOP\User::getIsGuest()) && (true)) {
									$feature = [
										'id' => 'fop_mail_host_box_dir_email_recipient_email_table',
										'title' => _('Alle Empfänger'),
										'order' => '4-100', // 4-100 (50)
										'mode' => 'tab', // tab (50)
										'position' => 'full', // 
										'collapsed' => 0, // 0 (51) / 1 (50)
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => null
									];
									$features[$feature['id']] = $feature;
									}
									
									if ((true) && (!\FOP\User::getIsGuest()) && (true)) {
									$feature = [
										'id' => 'fop_mail_host_box_dir_email_thread_email_table',
										'title' => _('Verlauf'),
										'order' => 'z510-100', // z510-100 (50)
										'mode' => 'tab', // tab (50)
										'position' => 'full', // 
										'collapsed' => 0, // 0 (51) / 1 (50)
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => null
									];
									$features[$feature['id']] = $feature;
									}
									
									if (true && (true)) {
									$feature = [
										'id' => 'buttons',
										'title' => _('Aktionen'),
										'order' => '300', // 300 (50)
										'mode' => 'area', // 
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => null
									];
									$features[$feature['id']] = $feature;
									}
									
									if (true && (false || true)) {
									$feature = [
										'id' => 'Text',
										'title' => _('Text'),
										'order' => 'z400', // z400 (60) / 200-Text (10-50)
										'mode' => 'region', // region (50)
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => '0' .'||'. (true ? 'true' : '0')
											 .'||'. (true ? 'true' : '0')
											
									];
									$features[$feature['id']] = $feature;
									}
									
									if (true && (false || false || false || false || false || true || true)) {
									$feature = [
										'id' => 'Sender_Empf_nger',
										'title' => _('Sender, Empfänger'),
										'order' => 'z200', // z200 (60) / 200-Sender, Empfänger (10-50)
										'mode' => 'region', // region (50)
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => '0' .'||'. '0' .'||'. '0' .'||'. '0' .'||'. '0' .'||'. (true ? 'true' : '0')
											 .'||'. (true ? 'true' : '0')
											
									];
									$features[$feature['id']] = $feature;
									}
									
									if (true && (false || true || false || false || false || false || false || false || false || false || true || false || false || false || false || false || false || false)) {
									$feature = [
										'id' => 'main',
										'title' => _('Daten'),
										'order' => '100', // 100 (20)
										'mode' => 'area', // 
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => '0' .'||'. (true ? 'true' : '0')
											 .'||'. '0' .'||'. '0' .'||'. '0' .'||'. '0' .'||'. '0' .'||'. '0' .'||'. '0' .'||'. '0' .'||'. (true ? 'true' : '0')
											 .'||'. '0' .'||'. '0' .'||'. '0' .'||'. '0' .'||'. '0' .'||'. '0' .'||'. '0'
									];
									$features[$feature['id']] = $feature;
									}
									
									if (true && (false || true || false || false || true)) {
									$feature = [
										'id' => 'Nachricht',
										'title' => _('Nachricht'),
										'order' => 'z300', // z300 (60) / 200-Nachricht (10-50)
										'mode' => 'region', // region (50)
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => '0' .'||'. (true ? 'true' : '0')
											 .'||'. '0' .'||'. '0' .'||'. (true ? 'true' : '0')
											
									];
									$features[$feature['id']] = $feature;
									}
									

									
									/* load order from database
										schema: fop_form_feature(user, form, subid, key, value)
										key = (order, mode, position, collapsed)
									*/
									$upbar_collapsed = false;
									// default values
									foreach (\FOP\Database::query('SELECT subid, '.qi('key').', (SELECT '.qi('value').' FROM fop_form_feature b WHERE a.subid = b.subid AND a.'.qi('key').' = b.'.qi('key').' AND '.qi('user').' = '.intval(\FOP\User::getID()).' GROUP BY '.qi('value').' ORDER BY COUNT(*) DESC LIMIT 1) AS '.qi('value').' FROM fop_form_feature a WHERE '.qi('user').' = '.intval(\FOP\User::getID()).' GROUP BY subid, '.qi('key'))->fetchAll(\PDO::FETCH_ASSOC) AS $setting) {
										if (isset($features[$setting['subid']])) {
											$features[$setting['subid']][$setting['key']] = $setting['value'];
										}
									}
									// form specific special values
									foreach (\FOP\Database::query('SELECT subid, '.qi('key').', '.qi('value').' FROM fop_form_feature a WHERE form = \'wf:fop_mail_host_box_dir_email:view\' AND '.qi('user').' = '.intval(\FOP\User::getID()).'')->fetchAll(\PDO::FETCH_ASSOC) AS $setting) {
										if (isset($features[$setting['subid']])) {
											$features[$setting['subid']][$setting['key']] = $setting['value'];
										} else if ($setting['subid'] == 'upbar' && $setting['key'] == 'collapsed') {
											$upbar_collapsed = (bool) $setting['value'];
										}
									}

									/* fill in the content of the features */
									if ((true) && (!\FOP\User::getIsGuest()) && (true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['fop_mail_host_box_dir_email_recipient_email_table']);
										?>
	<?php if ((!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest())) { ?>
	<div id="fop_mail_host_box_dir_email_recipient_email-table" class="fop-dv"><?php
		if (\EasyEditor\FormFeature::isCollapsed()) {
			// #3198 lazy rendering:
			echo '<div class="fop-lazy-reload" onclick="reloadfop_mail_host_box_dir_email_recipient_email()"></div>'; // CSS class .fop-lazy-reload will be clicked after being showed
		} else {
			\DataView\Fop_mail_host_box_dir_email_recipient_email::renderTabTableAction($id);
		}
	?></div>
	<?php } ?>
	<?php
										\EasyEditor\FormFeature::pop();
										$features['fop_mail_host_box_dir_email_recipient_email_table']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if ((true) && (!\FOP\User::getIsGuest()) && (true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['fop_mail_host_box_dir_email_thread_email_table']);
										?>
	<?php if ((!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest())) { ?>
	<div id="fop_mail_host_box_dir_email_thread_email-table" class="fop-dv"><?php
		if (\EasyEditor\FormFeature::isCollapsed()) {
			// #3198 lazy rendering:
			echo '<div class="fop-lazy-reload" onclick="reloadfop_mail_host_box_dir_email_thread_email()"></div>'; // CSS class .fop-lazy-reload will be clicked after being showed
		} else {
			\DataView\Fop_mail_host_box_dir_email_thread_email::renderTabTableAction($id);
		}
	?></div>
	<?php } ?>
	<?php
										\EasyEditor\FormFeature::pop();
										$features['fop_mail_host_box_dir_email_thread_email_table']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if (true && (true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['buttons']);
										?><div id='wf_fop_mail_host_box_dir_email_view_buttons' class='mdl-cell mdl-cell--12-col' style='flex-wrap: wrap;'>
		<?php if (true && $data['operation::view'] == 1 && $data['operation::edit'] == 1 && ((\FOP\User::getIsLoggedIn())) && (!\FOP\User::getIsGuest())) { ?><a title="<?php echo(_('editbtn')); ?>" class="detailbtn mdl-button mdl-js-button mdl-button--raised mdl-button--colored" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host_box_dir_email::editURL2(['id' => $data['ID'], 'popup' => $_GET['popup'] ?? null])); ?>"><i class='material-icons'>mode_edit</i> <?php echo(_('editbtn')); ?></a><?php } ?>&nbsp;<?php if (true) { ?><button onclick="$(this).closest('form').find('.mdl-textfield__error:visible').hide();
		$('[required]').removeAttr('required');
	" type="submit" name="ok" class="mdl-button mdl-js-button mdl-button--colored mdl-button--raised" ><i class="material-icons">check</i><?php echo(_('ok')); ?></button><?php } ?>
									&nbsp;
		<?php if (true && (!\FOP\User::getIsGuest())) { ?><a title="<?php echo(_('antworten')); ?>" class="detailbtn mdl-button mdl-js-button mdl-button--raised mdl-button--colored" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host_box_draft::answerURL2(['mail' => $data['ID'], 'popup' => $_GET['popup'] ?? null])); ?>"><i class='material-icons'>question_answer</i> <?php echo(_('antworten')); ?></a><?php } ?>&nbsp;
		<?php if (true && (!\FOP\User::getIsGuest())) { ?><a title="<?php echo(_('weiterleiten')); ?>" class="detailbtn mdl-button mdl-js-button mdl-button--raised mdl-button--colored" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host_box_draft::forwardURL2(['mail' => $data['ID'], 'popup' => $_GET['popup'] ?? null])); ?>"><i class='material-icons'>forward</i> <?php echo(_('weiterleiten')); ?></a><?php } ?>&nbsp;
		<?php if (true && (!\FOP\User::getIsGuest())) { ?><a title="<?php echo(sprintf(_('in %s umwandeln'), _('Aufgabe'))); ?>" class="detailbtn mdl-button mdl-js-button mdl-button--raised mdl-button--colored" href="<?php echo htmlentities(\TablesRouter\Aufgabe::createURL2(['email' => $data['ID'], 'popup' => $_GET['popup'] ?? null])); ?>"><i class='material-icons'>🎫</i> <?php echo(sprintf(_('in %s umwandeln'), _('Aufgabe'))); ?></a><?php } ?>&nbsp;
		<?php if (true && $data['operation::view'] == 1 && ((\FOP\User::getIsLoggedIn()))) { ?><a title="<?php echo(_('Löschen')); ?>" class="detailbtn mdl-button mdl-js-button mdl-button--raised mdl-button--colored" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host_box_dir_email::emailDeleteURL2(['id' => $data['ID'], 'popup' => $_GET['popup'] ?? null])); ?>"><i class='material-icons'>delete</i> <?php echo(_('Löschen')); ?></a><?php } ?>&nbsp;
		<?php if (true && $data['operation::view'] == 1 && ((\FOP\User::getIsLoggedIn()))) { ?><a title="<?php echo(_('Spam')); ?>" class="detailbtn mdl-button mdl-js-button mdl-button--raised mdl-button--colored" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host_box_dir_email::emailSpamURL2(['id' => $data['ID'], 'popup' => $_GET['popup'] ?? null])); ?>"><i class='material-icons'>block</i> <?php echo(_('Spam')); ?></a><?php } ?>&nbsp;
		<?php if (true && $data['operation::view'] == 1 && ((\FOP\User::getIsLoggedIn()))) { ?><a title="<?php echo(_('Als ungelesen Markieren')); ?>" class="detailbtn mdl-button mdl-js-button mdl-button--raised mdl-button--colored" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host_box_dir_email::emailFlagURL2(['id' => $data['ID'], 'popup' => $_GET['popup'] ?? null])); ?>"><i class='material-icons'>markunread</i> <?php echo(_('Als ungelesen Markieren')); ?></a><?php } ?>&nbsp;
		<?php if ($data['operation::delete'] == 1 && $data['operation::delete'] == 1 && ((false))) { ?><a title="<?php echo(_('deletebtn')); ?>" class="detailbtn mdl-button mdl-js-button mdl-button--raised mdl-button--colored" href="<?php echo htmlentities(\TablesRouter\Fop_mail_host_box_dir_email::deleteConfirmURL2(['id' => $data['ID'], 'popup' => $_GET['popup'] ?? null, 'from' => $_GET['from'] ?? \FOP\Session::getPayload('dv-fop_mail_host_box_dir_email')['from'] ?? null])); ?>"><i class='material-icons'>delete</i> <?php echo(_('deletebtn')); ?></a><?php } ?></div><script type='text/javascript'>
		// copy all buttons to #fop-upbar
		$(function () {
    var btn = document.getElementById("fop-bar-mainbutton");
    var upbar = $('#fop-upbar');
    var upbar_buttons = document.getElementById("fop-bar-container");

    // Check if the elements already exist
    if (!btn || !upbar_buttons) {
        if (!btn) {
            btn = $('<div id="fop-bar-mainbutton" class="mdl-button fop-button-half fop-button-margin mdl-button--raised"><i class="material-icons">keyboard_arrow_right</i></div>')
                .click(function () {
                    if (btn.find('i').text() == 'keyboard_arrow_right') {
                        upbar_buttons.fadeOut(400);
                        btn.find('i').text('keyboard_arrow_left');
                    } else {
                        upbar_buttons.fadeIn(400);
                        btn.find('i').text('keyboard_arrow_right');
                    }
                });
            upbar.append(btn);
        }

        if (!upbar_buttons) {
            upbar_buttons = $('<div id="fop-bar-container" style="max-width: 290px"></div>'); //dependant on the mdl-buttons width, caps of upbar buttons at exactly 4 buttons
            upbar.append(upbar_buttons);
        }

        var buttons = $('#wf_fop_mail_host_box_dir_email_view_buttons').find('.mdl-button');
        buttons.each(function (i, v) {
            var button = $(v);
            var newbutton = $('<div></div>');
            newbutton.attr('class', button.attr('class'));
            newbutton.attr('title', button.attr('title'));
            newbutton.append(button.find('.material-icons').clone(false));
            newbutton.click(function () {
                button[0].click();
            });
            upbar_buttons.append(newbutton);
        });
    }
});

	</script><?php
										\EasyEditor\FormFeature::pop();
										$features['buttons']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if (true && (false || true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['Text']);
										?><!--Feld "content": content -->
	<div class="mdl-cell mdl-cell--12-col column_content" style="display:block;" id="column_content"">
		
<div ng-non-bindable class='fop-textarea' >
<?php echo \FOP\Util::SanitizeUserHtml($data['content'], true); ?>
</div>

	</div><?php
										\EasyEditor\FormFeature::pop();
										$features['Text']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if (true && (false || false || false || false || false || true || true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['Sender_Empf_nger']);
										?><div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_senderDisplay_seen" id="column_senderDisplay_seen">
		<!-- Feld "senderdisplay": senderDisplay -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="senderDisplay"><?php echo(_('senderdisplay')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-content">
		
	<?php echo htmlentities($data['senderDisplay']); ?>
	</div>
		<!-- Feld "seen": seen -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="seen"><?php echo(_('seen')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-content">
		<?php if($data['seen'] == 1){ ?>✓<?php }else{ ?>✗<?php }?>
	</div>
	</div><div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_senderEmail_recipient" id="column_senderEmail_recipient">
		<!-- Feld "sender": senderEmail -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="senderEmail"><?php echo(_('sender')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-content">
		<span class='overflow-text'><a onclick="event.stopPropagation();<?php if ((!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest()) && (!\FOP\User::getIsGuest())) { ?>event.preventDefault(); window.open_over(document.baseURI + 'Tables/Fop_mail_host_box_draft/create?to=' + encodeURIComponent(this.href.substr(7)) + '&popup&from=' + encodeURIComponent(document.baseURI + 'jscloser.php?action=popup&close')); <?php } ?>
" href="<?php echo ('mailto:' . htmlentities(($data['senderEmail']))); ?>"><?php echo htmlentities($data['senderEmail']); ?></a></span>
	</div>
		<!-- Feld "recipient": recipient -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="recipient"><?php echo(_('recipient')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-content">
		
	<?php echo htmlentities($data['recipient']); ?>
	</div>
	</div><?php
										\EasyEditor\FormFeature::pop();
										$features['Sender_Empf_nger']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if (true && (false || true || false || false || false || false || false || false || false || false || true || false || false || false || false || false || false || false)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['main']);
										?><div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_Sender, Empfänger_Nachricht" id="column_Sender, Empfänger_Nachricht">
		
		
	</div>
	<?php
		$attachments = \FOP\Database::query('SELECT filename, fop_files.'.qi('ID').' FROM fop_files LEFT JOIN fop_mail_host_box_dir_email_attachment ON file = fop_files.'.qi('ID').' WHERE fop_mail_host_box_dir_email_attachment.email = ' . \FOP\Database::quote($data['ID']))->fetchAll();
 		foreach($attachments as $file){

                echo '<a class="mdl-button mdl-js-button mdl-button--colored mdl-button--raised" href="fop-files/'.$file['ID'].'/x" style="border-radius: 20px; margin-right: 10px; margin-bottom: 10px; background: rgb(220,220,220); color: rgb(0,0,0);"><span class="material-icons">attachment</span>'.$file['filename'].'</a>'; 
        	}
?>	<?php
										\EasyEditor\FormFeature::pop();
										$features['main']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if (true && (false || true || false || false || true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['Nachricht']);
										?><div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_timestamp_directory" id="column_timestamp_directory">
		<!-- Feld "receivedat": timestamp -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="timestamp"><?php echo(_('receivedat')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-content">
		
	<?php echo htmlentities(($data['timestamp']) ? strftime(_('datetimeformat_php2'), intval($data['timestamp'])) : ''); ?>
	</div>
		<!-- Feld "directory": directory -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="directory"><?php echo(_('directory')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-content">
		<?php
	
	$sql = 'SELECT '.qi('ID').' AS '.qi('ID').', CONCAT('.qi('fop_mail_host_box_dir').'.'.qi('name').', \' - \', (SELECT ('.qi('tcayeuX5').'.'.qi('from_address').') FROM '.qi('fop_mail_host_box').' '.qi('tcayeuX5').' WHERE '.qi('tcayeuX5').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir').'.'.qi('mailbox').' LIMIT 1)) AS description, ((COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir').'.'.qi('mailbox').' LIMIT 1), FALSE))) AS '.qi('canView').' FROM '.qi('fop_mail_host_box_dir').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($data['directory']);
	$fop_mail_host_box_dir_result = \FOP\Database::query($sql);
	if ($fop_mail_host_box_dir_row = $fop_mail_host_box_dir_result->fetch(\PDO::FETCH_ASSOC)) {
		if ($fop_mail_host_box_dir_row['canView']) echo "<a onclick=\"event.preventDefault(); open_url(this.href, false);\" href=\"" . \TablesRouter\Fop_mail_host_box_dir::viewURL($data['directory'], ['from' => \FOP\Util::getBackURL()]) . "\" class=\"tbl-link\" data-tbl=\"fop_mail_host_box_dir\" data-id=\"".htmlentities($fop_mail_host_box_dir_row['ID'])."\">";echo htmlentities($fop_mail_host_box_dir_row['description']);if ($fop_mail_host_box_dir_row['canView']) echo "</a>";
	} else {
		echo htmlentities(_('') ?: '-');
	}
	
?>

	</div>
	</div>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_subject" id="column_subject">
		<!-- Feld "subject": subject -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="subject"><?php echo(_('subject')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		
	<?php echo htmlentities($data['subject']); ?>
	</div>
	</div><?php
										\EasyEditor\FormFeature::pop();
										$features['Nachricht']['html'] = ob_get_contents();
										ob_end_clean();
									}
									

									uasort($features, function ($a, $b) {
										return strnatcmp($a['order'], $b['order']);
									});
									foreach ($features AS $feature) {
										\EasyEditor\FormFeature::render($feature);
									}
									?><script type='text/javascript'>
										function setCFF(id, key, value) {
											<?php if(!\FOP\User::getIsGuest()) { ?>
											$.get('FOP/Index/setCFF?form=wf%3Afop_mail_host_box_dir_email%3Aview&subid=' + encodeURIComponent(id) + '&key=' + encodeURIComponent(key) + '&value=' + encodeURIComponent(value)).then(function () {
												if (key == 'reset') {
													location.reload();
												}
											});
											<?php } /* EditAccess */ ?>
										}
										function setCFFOrder(fids) {
											<?php if(!\FOP\User::getIsGuest()) { ?>
											$.get('FOP/Index/setCFFOrder?form=wf%3Afop_mail_host_box_dir_email%3Aview&fids=' + encodeURIComponent(JSON.stringify(fids)));
											<?php } /* EditAccess */ ?>
										}
										$(function () {
											refreshTabHeaders($('#cardform-wf_fop_mail_host_box_dir_email_view')); /* provided in js/form.js */
											// preselection
											if (location.hash.startsWith('#select:')) {
												$('[name="' + window.location.hash.slice(8) + '"]').focus().select();
											} else {
												$('#cardform-wf_fop_mail_host_box_dir_email_view input[type!="hidden"],textarea,select[tabindex!="-1"]').not('.fop-disabled *').filter(':visible:first').focus().select();
											}
										});

										$(window).keydown(function(event) {
											 if (event.ctrlKey && String.fromCharCode(event.which).toLowerCase() == 's') {
												 event.preventDefault();
												 $('button[type=submit]').click();
												 return false;
											 }
										});

										
										$(document).on('keyup',function(evt) {
										   if (evt.keyCode == 27) {
												if (window.parent) {
													window.close(); // iframe:close
												} else {
													window.history.back();
												}
											}
												});
										
									</script>
									<script></script> <!-- Benötigt, damit die Striped-Zählung unterbunden wird und das nachfolgende Card weiß bleibt-->
									<div class="grid-card mdl-cell mdl-cell--12-col">
										<?php
		$mail = \FOP\Database::query('SELECT fop_mail_host_box_dir_email.uid, fop_mail_host_box_dir_email.boxid, fop_mail_host_box_dir.'.qi('ID').', fop_mail_host_box_dir.imap_name FROM fop_mail_host_box_dir_email LEFT JOIN fop_mail_host_box ON fop_mail_host_box_dir_email.boxid = fop_mail_host_box.'.qi('ID').' LEFT JOIN fop_mail_host_box_dir ON fop_mail_host_box_dir_email.directory = fop_mail_host_box_dir.'.qi('ID').' WHERE NOT COALESCE(fop_mail_host_box_dir_email.seen, FALSE) AND fop_mail_host_box_dir_email.'.qi('ID').' = ' . \FOP\Database::quote($id))->fetch(\PDO::FETCH_ASSOC);
		if ($mail) {
			try {
				$mbox = \Tables\Fop_mail_host_box_dir::imap_open($mail['boxid'], $mail['imap_name'], '');
				imap_setflag_full($mbox, $mail['uid'], '\\Seen', ST_UID);
				\FOP\Database::query('UPDATE fop_mail_host_box_dir_email SET seen = TRUE WHERE '.qi('ID').' = ' . \FOP\Database::quote($id));
				imap_close($mbox,CL_EXPUNGE);
			} catch (Exception $e) {
				imap_close($mbox,CL_EXPUNGE);
			}
		}
 ?>
									</div>
									

							</form>
							

							</div>
							<div class="content" id="focus-supersearch">
							</div>
							<div class="content" id="focus-supersearch">
		<script type='text/javascript'>
			$(function () {
				var focusfield = $('#supersearch');
				if (focusfield.length) {
					focusfield[0].focus();
					focusfield[0].select();
				}
			});
		</script>
	
							</div>
							<div class="content" id="~spacer"><?php if (!isset($_GET['popup'])) { ?><div style="padding-bottom: 10cm;"></div><?php } ?>
							</div>
						<?php if (!isset($_GET['popup'])) { ?>
					</div>
				</main>
				
			</div>
		<?php } else { ?></div><?php } ?>
<?php if (!isset($_GET['popup'])) { ?><div class='fop-seal'></div><?php } ?></body></html><?php
    // --- BLOCK: main-6 ---
    }
    
  }

  public static function createAction($column_directory = null ) { 
    
    // Methodenimplementierung überschrieben.
    throw new \FOP\AccessDeniedException();return false;
  }

  public static function editAction($id = null ) { 
    
    
    // --- BLOCK: 0_CSRFValidate ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') \FOP\Session::validateCSRFToken(); else \FOP\Session::getCSRFToken();

    // --- BLOCK: 0_CSRF_ensure ---
    
	\FOP\Session::getCSRFToken();
    // --- BLOCK: access ---
    if(!((!\FOP\User::getIsGuest()))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access+validators ---
    
	if ($_SERVER['REQUEST_METHOD'] === 'POST') {
		$data = self::view($id);
		/* Validatoren */
		
		if ((!isset($_POST['cancel']))) \Types\Fop_mail_host_box_dir::validate($_POST['directory']);

		
		/* Sanitizer */

		if (((false)) && ($data['timestamp::canEdit'] == 1)) $_POST['timestamp'] = \FOP\Sanitizers::convert_datetime_to_unix_timestamp($_POST['timestamp']);
		if (((false)) && ($data['senderEmail::canEdit'] == 1)) $_POST['senderEmail'] = \FOP\Sanitizers::no_text($_POST['senderEmail']);
		if (((false)) && ($data['content::canEdit'] == 1)) $_POST['content'] = \FOP\Sanitizers::htmlentities_decode($_POST['content']);
		if ((!isset($_POST['cancel']))) $_POST['directory'] = \FOP\Sanitizers::null_filter($_POST['directory']);

		
	}
	
    // --- BLOCK: access+~directory:68cb1cba2d73fab194f58a813537b5285ce9422da3990dfa5f902fff759dd706:if ---
    
		if ($_SERVER['REQUEST_METHOD'] === 'POST') {
			if (!isset($_POST['cancel']) && !(((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('PXLLPZCy').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' '.qi('PXLLPZCy').' WHERE '.qi('PXLLPZCy').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['directory']) . '')->fetchColumn()))) !== null && ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('PXLLPZCy').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' '.qi('PXLLPZCy').' WHERE '.qi('PXLLPZCy').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['directory']) . '')->fetchColumn()))) !== '0' ? ((\FOP\Util::FalseToNull(\FOP\Database::query('SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('PXLLPZCy').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' '.qi('PXLLPZCy').' WHERE '.qi('PXLLPZCy').'.'.qi('ID').' = ' . \FOP\Database::quote($_POST['directory']) . '')->fetchColumn()))) : (false))) throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: access-item-fop_mail_host_box_dir_email-edit ---
    
		if ($id !== null && \FOP\Database::query('SELECT (COALESCE((SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('KcSSV43E').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' '.qi('KcSSV43E').' WHERE '.qi('KcSSV43E').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('directory').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir_email').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() != 1) {
			throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: main ---
    
		// Main block
	
    // --- BLOCK: main-1 ---
    if ($_SERVER['REQUEST_METHOD'] == 'POST') {
		if (!isset($_POST['cancel'])) {
			\FOP\Database::beginTransaction();
    // --- BLOCK: main-2:save-clone-prepare ---
    
		$data = self::view($id);
	
    // --- BLOCK: main-2:save-main ---
    
		$data_edit = [];
		if (((false)) && ($data['timestamp::canEdit'] == 1)) $data_edit['timestamp'] = $_POST['timestamp'];
		if (((false)) && ($data['senderDisplay::canEdit'] == 1)) $data_edit['senderDisplay'] = $_POST['senderDisplay'];
		if (((false)) && ($data['senderEmail::canEdit'] == 1)) $data_edit['senderEmail'] = $_POST['senderEmail'];
		if (((false)) && ($data['subject::canEdit'] == 1)) $data_edit['subject'] = $_POST['subject'];
		if (((false)) && ($data['content::canEdit'] == 1)) $data_edit['content'] = $_POST['content'];
		if ((!isset($_POST['cancel']))) $data_edit['directory'] = $_POST['directory'];
		if (((false)) && ($data['seen::canEdit'] == 1)) $data_edit['seen'] = $_POST['seen'];
		self::edit($id, $data_edit);
		if (isset($data_edit['ID'])) {
			$id = $data_edit['ID'];
		}
	
    // --- BLOCK: main-3 ---
    
			\FOP\Database::commitTransaction();
			
		}
		
		if (isset($_POST['cancel'])) {
			
			if (isset($_POST['fop-from']) && $_POST['fop-from']) {
				// Redirect zu fop-from
				header('Location: ' . preg_replace('/&insert_param=(.*)$/', '&$1=' . ($id instanceof \FOP\IDList ? $id->toString() : $id), $_POST['fop-from']));
			} else {
				header('Location: ' . \TablesRouter\Fop_mail_host_box_dir_email::viewURL2(['id' => $id, 'popup' => $_GET['popup'] ?? null]));
			}
			die();
	
		}
		if (isset($_POST['save'])) {
			
			if (isset($_POST['fop-from']) && $_POST['fop-from']) {
				// Redirect zu fop-from
				header('Location: ' . preg_replace('/&insert_param=(.*)$/', '&$1=' . ($id instanceof \FOP\IDList ? $id->toString() : $id), $_POST['fop-from']));
			} else {
				header('Location: ' . \TablesRouter\Fop_mail_host_box_dir_email::viewURL2(['id' => $id, 'popup' => $_GET['popup'] ?? null]));
			}
			die();
	
		}
		die(json_encode($_POST));
	} else {
    // --- BLOCK: main-4:load-main ---
    
		$data = self::view($id); // TODO: klären, wer die Funktion bereitstellt (momentan crud/view.fop)
	
    // --- BLOCK: main-5 ---
    ?><?php
			header('Content-Type: text/html; charset=UTF-8');
			header('X-XSS-Protection: 1; mode=block');
			header('Strict-Transport-Security: max-age=63072000');
			header('X-Content-Type-Options: nosniff');
			header("Content-Security-Policy: default-src *  data: blob: 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * data: blob: 'unsafe-inline'; font-src * data: blob: 'unsafe-inline';");


		?><!DOCTYPE html><html><head><title><?php echo htmlentities(str_replace('%s', \FOP\Database::query('SELECT CONCAT((SELECT (CONCAT('.qi('CBD4eCc3').'.'.qi('display').', \' <\', '.qi('CBD4eCc3').'.'.qi('address').', \'>\')) FROM '.qi('fop_mail_host_box_dir_email_recipient').' '.qi('CBD4eCc3').' WHERE '.qi('CBD4eCc3').'.'.qi('email').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('ID').' LIMIT 1), \' - \', '.qi('fop_mail_host_box_dir_email').'.'.qi('subject').', \' (\', '.(\FOP\Database::getDriver() == 'mysql' ? 'DATE_FORMAT(FROM_UNIXTIME' : 'to_char(to_timestamp') . '('.qi('fop_mail_host_box_dir_email').'.'.qi('timestamp').')' . ', '.\FOP\Database::sessionVarSQL('datetimeformat').'), \')\') AS description FROM '.qi('fop_mail_host_box_dir_email').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() ?: '', _('edit %s'))); ?></title><base href='<?php echo \FOP\Util::getCurrentBaseurl(); ?>'><meta name="google" content="notranslate"><meta http-equiv="Content-Language" content="<?php echo htmlentities(\FOP\I18n::getLocale()); ?>"><meta charset="utf-8"><link rel="stylesheet" type="text/css" href="style_dependencies.css?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"><link rel="stylesheet" type="text/css" href="style.css?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"><script type="text/javascript" src="js/script_dependencies.js?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"></script><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="mobile-web-app-capable" content="yes"><link rel="manifest" href="manifest.webmanifest"><script type="text/javascript">moment.locale('<?php echo(\FOP\I18n::getShortLocale()); ?>');</script><script type="text/javascript" src="js/form.js"></script><script type="text/javascript">window.globals = <?php
	echo json_encode(['user:superadmin' => /* TODO: resanitizer später mal */(integer) \FOP\User::getSuperadmin(), 'user:mitglied' => /* TODO: resanitizer später mal */(integer) \FOP\User::getMitglied(), 'user:gruppe' => /* TODO: resanitizer später mal */(integer) \FOP\User::getGruppe(), 'user:campaign' => /* TODO: resanitizer später mal */(integer) \FOP\User::getCampaign(), 'user:sammlung' => /* TODO: resanitizer später mal */(integer) \FOP\User::getSammlung(), 'user:protokoll' => /* TODO: resanitizer später mal */(integer) \FOP\User::getProtokoll(), 'user:ID' => /* TODO: resanitizer später mal */(integer) \FOP\User::getID(), 'user:buchhaltung' => /* TODO: resanitizer später mal */(integer) \FOP\User::getBuchhaltung()]);
?>;</script><script type="text/javascript" src="angular/<?php echo(\FOP\I18n::getShortLocale()); ?>/js/alltypes.js?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"></script><script type="text/javascript" src="angular/angular-i18n/angular-locale_<?php echo \FOP\I18n::getAngularLocale(); ?>.js"></script><script type="text/javascript" src="js/date-filter.js"></script><script type="text/javascript" src="js/dropdown.js"></script><script type="text/javascript" src="js/numeric.js"></script><script type="text/javascript" src="js/getparam.js"></script><script type="text/javascript" src="js/tables.js"></script>
		<script type="text/javascript" src="js/parsehash.js"></script><script type="text/javascript">
		window.query = <?php echo json_encode($_GET, JSON_FORCE_OBJECT); ?>;
		window.baseurl = <?php echo json_encode(\FOP\Util::getCurrentBaseurl()); ?>;

		window.i18n_weiter = <?php echo json_encode(_('Weiter'));?>;
		//Filter I18n:
		window.i18n_quartal = <?php echo json_encode(_('Quarter'));?>;
		window.i18n_alle = <?php echo json_encode(_('All'));?>;
		window.i18n_leere = <?php echo json_encode(_('Empty'));?>;
		window.i18n_tag = <?php echo json_encode(_('Tag'));?>;
		window.i18n_woche = <?php echo json_encode(_('Woche'));?>;
		window.i18n_zeitraum = <?php echo json_encode(_('Period'));?>;
		window.i18n_monat = <?php echo json_encode(_('Monat'));?>;
		window.i18n_jahr = <?php echo json_encode(_('Jahr'));?>;
		window.i18n_von = <?php echo json_encode(_('filters_from'));?>;
		window.i18n_bis = <?php echo json_encode(_('filters_to'));?>;
		window.i18n_tabButton = <?php echo json_encode(_('open_in_new_tab'));?>;
		window.i18n_closeButton = <?php echo json_encode(_('close'));?>;
		</script></head><script type="text/javascript">const fopPushPublicKey = '<?php echo(addslashes(\FOP\Configuration::getFOPPushPublicKey())); ?>';
        const fopUserID = <?php echo(intval(\FOP\User::getID())); ?>;
        var fopPushDisabled = false;
    </script><script type="text/javascript" src="js/serviceworkersetup.js"></script><body ng-app='app'>
		<div class='mdl-js-snackbar mdl-snackbar' id='snackbar'>
			<div class='mdl-snackbar__text'></div>
			<button class='mdl-snackbar__action' type='button'></button>
		</div>
		<script>
			var snackbar = document.querySelector('#snackbar');
			componentHandler.upgradeElement(snackbar, 'MaterialSnackbar');
			$(function () {
				setTimeout(function () {
					$('.fop-layout').scrollTop(0);
				}, 0);
			});
		</script>

		<?php if (isset($_GET['popup'])) { ?>
		<header class="fop-header mdl-layout__header mdl-layout__header mdl-layout__header--scroll">
				<div class="mdl-layout__header-row">
					<span class="mdl-layout-title"><?php echo htmlentities(str_replace('%s', \FOP\Database::query('SELECT CONCAT((SELECT (CONCAT('.qi('CBD4eCc3').'.'.qi('display').', \' <\', '.qi('CBD4eCc3').'.'.qi('address').', \'>\')) FROM '.qi('fop_mail_host_box_dir_email_recipient').' '.qi('CBD4eCc3').' WHERE '.qi('CBD4eCc3').'.'.qi('email').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('ID').' LIMIT 1), \' - \', '.qi('fop_mail_host_box_dir_email').'.'.qi('subject').', \' (\', '.(\FOP\Database::getDriver() == 'mysql' ? 'DATE_FORMAT(FROM_UNIXTIME' : 'to_char(to_timestamp') . '('.qi('fop_mail_host_box_dir_email').'.'.qi('timestamp').')' . ', '.\FOP\Database::sessionVarSQL('datetimeformat').'), \')\') AS description FROM '.qi('fop_mail_host_box_dir_email').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() ?: '', _('edit %s'))); ?></span><div class="mdl-layout-spacer"></div><span class="noprint mdl-layout-title mdl-layout--large-screen-only"><div class="mdl-textfield mdl-js-textfield"><input id="supersearch" accesskey="f" class="mdl-textfield__input" type="text" onkeydown="if (event.keyCode == 13 && this.value) window.location.href = 'FOP/Index/searchURL?q=' + encodeURIComponent(this.value) + '&from=<?php echo htmlentities(urlencode(\FOP\Util::getBackUrl())); ?>';" value="<?php echo htmlentities($_GET['q'] ?? ''); ?>" style="border-bottom: 1px solid white;"/><label class="mdl-textfield__label" style="color: inherit"><?php echo(_('search')); ?> - <?php
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
			// MAC: Control+ davor
			echo 'Control + ';
		}
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {
			// Firefox
			if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
				// MAC: Control + Alt + key
				echo 'Alt + F';
			} else {
				echo 'Alt + Shift + F';
			}
		} else {
			// Internet Explorer, Chrome, Safari, Opera
			echo 'Alt + F';
		}
	?></label></div></span><i onclick='addFav(null)' class='material-icons fop-favorites' id='favorites_button'>star_border</i>
				</div>
      	</header>
			<style>
				.content {
					margin-top: 0px !important;
				}
			</style>
			<div id='content' class='popup' >
		<?php } else { ?>
			<div class="fop-layout mdl-layout mdl-js-layout mdl-layout--fixed-drawer mdl-layout--fixed-header">
			<header class="fop-header mdl-layout__header mdl-layout__header mdl-layout__header--scroll">
				<div class="mdl-layout__header-row">
					<span class="mdl-layout-title"><?php echo htmlentities(str_replace('%s', \FOP\Database::query('SELECT CONCAT((SELECT (CONCAT('.qi('CBD4eCc3').'.'.qi('display').', \' <\', '.qi('CBD4eCc3').'.'.qi('address').', \'>\')) FROM '.qi('fop_mail_host_box_dir_email_recipient').' '.qi('CBD4eCc3').' WHERE '.qi('CBD4eCc3').'.'.qi('email').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('ID').' LIMIT 1), \' - \', '.qi('fop_mail_host_box_dir_email').'.'.qi('subject').', \' (\', '.(\FOP\Database::getDriver() == 'mysql' ? 'DATE_FORMAT(FROM_UNIXTIME' : 'to_char(to_timestamp') . '('.qi('fop_mail_host_box_dir_email').'.'.qi('timestamp').')' . ', '.\FOP\Database::sessionVarSQL('datetimeformat').'), \')\') AS description FROM '.qi('fop_mail_host_box_dir_email').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() ?: '', _('edit %s'))); ?></span><div class="mdl-layout-spacer"></div><span class="noprint mdl-layout-title mdl-layout--large-screen-only"><div class="mdl-textfield mdl-js-textfield"><input id="supersearch" accesskey="f" class="mdl-textfield__input" type="text" onkeydown="if (event.keyCode == 13 && this.value) window.location.href = 'FOP/Index/searchURL?q=' + encodeURIComponent(this.value) + '&from=<?php echo htmlentities(urlencode(\FOP\Util::getBackUrl())); ?>';" value="<?php echo htmlentities($_GET['q'] ?? ''); ?>" style="border-bottom: 1px solid white;"/><label class="mdl-textfield__label" style="color: inherit"><?php echo(_('search')); ?> - <?php
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
			// MAC: Control+ davor
			echo 'Control + ';
		}
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {
			// Firefox
			if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
				// MAC: Control + Alt + key
				echo 'Alt + F';
			} else {
				echo 'Alt + Shift + F';
			}
		} else {
			// Internet Explorer, Chrome, Safari, Opera
			echo 'Alt + F';
		}
	?></label></div></span><i onclick='addFav(null)' class='material-icons fop-favorites' id='favorites_button'>star_border</i>
				</div>
      		</header>


				<?php  \EasyEditor\Navigation::render(); ?>
      
				<main class="mdl-layout__content" id="content">
					<div class="fop-content">
						<?php } ?>
						
							<div class="content" id="1">
								

								<form
									
									action="<?php echo \TablesRouter\Fop_mail_host_box_dir_email::editURL2(['popup' => $_GET['popup'] ?? null, 'id' => $id]); ?>"
									method="post"
									enctype="multipart/form-data" ng-submit='submit($event)'
									onsubmit="
										if (window.running_uploads) {
											event.preventDefault();
											alert('<?php echo htmlentities(json_encode(_('fileUploadStillActive')));?>');
										}
									"
								 
								id="cardform-wf_fop_mail_host_box_dir_email_edit"
								style="width: 100%; height: 100%;"
								class='mdl-grid'
									ng-controller="FormWf_fop_mail_host_box_dir_email_edit" ng-init="form = <?php echo htmlentities(json_encode(['directory' => $data['directory']]));
									?>;"
								>
								<?php
								 echo '<input type="hidden" name="csrftoken" value="' . htmlentities(\FOP\Session::getCSRFToken()) . '">';
								 if (isset($_GET['from'])) echo '<input type="hidden" name="fop-from" value="' . htmlentities($_GET['from']) . '">';
								 ?>
								<div id='fop-upbar'></div>
								
									<?php
									$features = [];
									if (true && (true)) {
									$feature = [
										'id' => 'buttons',
										'title' => _('Aktionen'),
										'order' => '300', // 300 (50)
										'mode' => 'area', // 
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => null
									];
									$features[$feature['id']] = $feature;
									}
									
									if (true && (false || false || false || false || false || false || false || false || false || false || false)) {
									$feature = [
										'id' => 'main',
										'title' => _('Daten'),
										'order' => '100', // 100 (20)
										'mode' => 'area', // 
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => '0' .'||'. '0' .'||'. '0' .'||'. '0' .'||'. '0' .'||'. '0' .'||'. '0' .'||'. '0' .'||'. '0' .'||'. '0' .'||'. '0'
									];
									$features[$feature['id']] = $feature;
									}
									
									if (true && (false || ((false)) && ($data['senderDisplay::canEdit'] == 1) || ((false)) && ($data['senderEmail::canEdit'] == 1) || ((false)) && ($data['seen::canEdit'] == 1))) {
									$feature = [
										'id' => 'Sender_Empf_nger',
										'title' => _('Sender, Empfänger'),
										'order' => 'z200', // z200 (60) / 200-Sender, Empfänger (10-50)
										'mode' => 'region', // region (50)
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => '0' .'||'. (((false)) && ($data['senderDisplay::canEdit'] == 1) ? 'true' : '0')
											 .'||'. (((false)) && ($data['senderEmail::canEdit'] == 1) ? 'true' : '0')
											 .'||'. (true ? 'true' : '0')
											 .'||'. (((false)) && ($data['seen::canEdit'] == 1) ? 'true' : '0')
											
									];
									$features[$feature['id']] = $feature;
									}
									
									if (true && (false || ((false)) && ($data['content::canEdit'] == 1))) {
									$feature = [
										'id' => 'Text',
										'title' => _('Text'),
										'order' => 'z400', // z400 (60) / 200-Text (10-50)
										'mode' => 'region', // region (50)
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => '0' .'||'. (true ? 'true' : '0')
											 .'||'. (((false)) && ($data['content::canEdit'] == 1) ? 'true' : '0')
											
									];
									$features[$feature['id']] = $feature;
									}
									
									if (true && (false || ((false)) && ($data['subject::canEdit'] == 1) || ((false)) && ($data['timestamp::canEdit'] == 1) || (!isset($_POST['cancel'])))) {
									$feature = [
										'id' => 'Nachricht',
										'title' => _('Nachricht'),
										'order' => 'z300', // z300 (60) / 200-Nachricht (10-50)
										'mode' => 'region', // region (50)
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => '0' .'||'. (((false)) && ($data['subject::canEdit'] == 1) ? 'true' : '0')
											 .'||'. (((false)) && ($data['timestamp::canEdit'] == 1) ? 'true' : '0')
											 .'||'. ((!isset($_POST['cancel'])) ? 'true' : '0')
											
									];
									$features[$feature['id']] = $feature;
									}
									

									
									/* load order from database
										schema: fop_form_feature(user, form, subid, key, value)
										key = (order, mode, position, collapsed)
									*/
									$upbar_collapsed = false;
									// default values
									foreach (\FOP\Database::query('SELECT subid, '.qi('key').', (SELECT '.qi('value').' FROM fop_form_feature b WHERE a.subid = b.subid AND a.'.qi('key').' = b.'.qi('key').' AND '.qi('user').' = '.intval(\FOP\User::getID()).' GROUP BY '.qi('value').' ORDER BY COUNT(*) DESC LIMIT 1) AS '.qi('value').' FROM fop_form_feature a WHERE '.qi('user').' = '.intval(\FOP\User::getID()).' GROUP BY subid, '.qi('key'))->fetchAll(\PDO::FETCH_ASSOC) AS $setting) {
										if (isset($features[$setting['subid']])) {
											$features[$setting['subid']][$setting['key']] = $setting['value'];
										}
									}
									// form specific special values
									foreach (\FOP\Database::query('SELECT subid, '.qi('key').', '.qi('value').' FROM fop_form_feature a WHERE form = \'wf:fop_mail_host_box_dir_email:edit\' AND '.qi('user').' = '.intval(\FOP\User::getID()).'')->fetchAll(\PDO::FETCH_ASSOC) AS $setting) {
										if (isset($features[$setting['subid']])) {
											$features[$setting['subid']][$setting['key']] = $setting['value'];
										} else if ($setting['subid'] == 'upbar' && $setting['key'] == 'collapsed') {
											$upbar_collapsed = (bool) $setting['value'];
										}
									}

									/* fill in the content of the features */
									if (true && (true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['buttons']);
										?><div id='wf_fop_mail_host_box_dir_email_edit_buttons' class='mdl-cell mdl-cell--12-col' style='flex-wrap: wrap;'><?php if (true) { ?><button onclick="
		var errors = $(this).closest('form').find('.fop-form-error:visible, .is-invalid').filter((i, x) => $(x).parents('.novalidate').length ? false : true);
		if (errors.length) {
			event.preventDefault();
			alert(errors.closest('.fop-form-content').prev('.fop-form-label').text() + ' Es sind noch Fehler im Formular bei Feld');
			return;
		} /* TODO: i18n */
		
	" type="submit" name="save" class="mdl-button mdl-js-button mdl-button--colored mdl-button--raised" ><i class="material-icons">save</i><?php echo(_('save')); ?></button><?php } ?>
									&nbsp;<?php if (true) { ?><button onclick="$(this).closest('form').find('.mdl-textfield__error:visible').hide();
		$('[required]').removeAttr('required');
	" type="submit" name="cancel" class="mdl-button mdl-js-button mdl-button--colored mdl-button--raised" ><i class="material-icons">cancel</i><?php echo(_('cancel')); ?></button><?php } ?>
									</div><script type='text/javascript'>
		// copy all buttons to #fop-upbar
		$(function () {
    var btn = document.getElementById("fop-bar-mainbutton");
    var upbar = $('#fop-upbar');
    var upbar_buttons = document.getElementById("fop-bar-container");

    // Check if the elements already exist
    if (!btn || !upbar_buttons) {
        if (!btn) {
            btn = $('<div id="fop-bar-mainbutton" class="mdl-button fop-button-half fop-button-margin mdl-button--raised"><i class="material-icons">keyboard_arrow_right</i></div>')
                .click(function () {
                    if (btn.find('i').text() == 'keyboard_arrow_right') {
                        upbar_buttons.fadeOut(400);
                        btn.find('i').text('keyboard_arrow_left');
                    } else {
                        upbar_buttons.fadeIn(400);
                        btn.find('i').text('keyboard_arrow_right');
                    }
                });
            upbar.append(btn);
        }

        if (!upbar_buttons) {
            upbar_buttons = $('<div id="fop-bar-container" style="max-width: 290px"></div>'); //dependant on the mdl-buttons width, caps of upbar buttons at exactly 4 buttons
            upbar.append(upbar_buttons);
        }

        var buttons = $('#wf_fop_mail_host_box_dir_email_edit_buttons').find('.mdl-button');
        buttons.each(function (i, v) {
            var button = $(v);
            var newbutton = $('<div></div>');
            newbutton.attr('class', button.attr('class'));
            newbutton.attr('title', button.attr('title'));
            newbutton.append(button.find('.material-icons').clone(false));
            newbutton.click(function () {
                button[0].click();
            });
            upbar_buttons.append(newbutton);
        });
    }
});

	</script><?php
										\EasyEditor\FormFeature::pop();
										$features['buttons']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if (true && (false || false || false || false || false || false || false || false || false || false || false)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['main']);
										?><?php
										\EasyEditor\FormFeature::pop();
										$features['main']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if (true && (false || ((false)) && ($data['senderDisplay::canEdit'] == 1) || ((false)) && ($data['senderEmail::canEdit'] == 1) || ((false)) && ($data['seen::canEdit'] == 1))) {
										ob_start();
										\EasyEditor\FormFeature::push($features['Sender_Empf_nger']);
										?><?php if (((false)) && ($data['senderDisplay::canEdit'] == 1)) { ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_senderDisplay" id="column_senderDisplay">
		<!-- Feld "senderdisplay": senderDisplay -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="senderDisplay"><?php echo(_('senderdisplay')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<div class="mdl-textfield mdl-js-textfield"><input onkeydown="
		if (event.keyCode == 13) {
			event.preventDefault();
			event.stopPropagation();
			tabNext(this);
			return false;
		}
	"  class="mdl-textfield__input"  type="text" name="senderDisplay"  value="<?php echo htmlentities($data['senderDisplay']); ?>"/><span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></div>
	</div>
	</div><?php } ?><?php if (((false)) && ($data['senderEmail::canEdit'] == 1)) { ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_senderEmail" id="column_senderEmail">
		<!-- Feld "sender": senderEmail -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="senderEmail"><?php echo(_('sender')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<div class="mdl-textfield mdl-js-textfield"><input class="mdl-textfield__input" type="email" name="senderEmail"  id="senderEmail" value="<?php echo htmlentities($data['senderEmail']); ?>"/><label class="mdl-textfield__label" for="senderEmail"><?php echo(_('email')); ?></label>  <span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></div>
	</div>
	</div><?php } ?><?php if (((false)) && ($data['seen::canEdit'] == 1)) { ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_seen" id="column_seen">
		<!-- Feld "seen": seen -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="seen"><?php echo(_('seen')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<input type="hidden" name="seen" id="seen" value="<?php echo ($data['seen']) ? '1' : '0'; ?>"/><label class="mdl-checkbox mdl-js-checkbox" style="width: unset;"><input onkeydown="
      if (event.keyCode == 13) {
         event.preventDefault();
         event.stopPropagation();
         tabNext(this);
         return false;
      }
   "  class="mdl-checkbox__input" id="seen__checkbox" type="checkbox" onchange="this.parentElement.previousElementSibling.value = this.checked ? 1 : 0;"<?php if ($data['seen']) echo ' checked'; ?>><span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></label>
	</div>
	</div><?php } ?><?php
										\EasyEditor\FormFeature::pop();
										$features['Sender_Empf_nger']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if (true && (false || ((false)) && ($data['content::canEdit'] == 1))) {
										ob_start();
										\EasyEditor\FormFeature::push($features['Text']);
										?><?php if (((false)) && ($data['content::canEdit'] == 1)) { ?><!--Feld "content": content -->
	<div class="mdl-cell mdl-cell--12-col column_content" style="display:block;" id="column_content"">
		
	<div tinymce-locale="<?php echo \FOP\I18n::getShortLocale(); ?>">
	
	<textarea ng-non-bindable rows="22" cols="50" name="content" class="html-html_protokoll_email"><?php echo htmlentities($data['content']); ?></textarea>
	</div>
	</div><?php } ?><?php
										\EasyEditor\FormFeature::pop();
										$features['Text']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if (true && (false || ((false)) && ($data['subject::canEdit'] == 1) || ((false)) && ($data['timestamp::canEdit'] == 1) || (!isset($_POST['cancel'])))) {
										ob_start();
										\EasyEditor\FormFeature::push($features['Nachricht']);
										?><?php if (((false)) && ($data['timestamp::canEdit'] == 1)) { ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_timestamp" id="column_timestamp">
		<!-- Feld "receivedat": timestamp -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="timestamp"><?php echo(_('receivedat')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<div class="mdl-textfield mdl-js-textfield"><input onkeydown="
		if (event.keyCode == 13) {
			event.preventDefault();
			event.stopPropagation();
			tabNext(this);
			return false;
		}
	" ts-locale='<?php echo (\FOP\I18n::getShortLocale()); ?>' ts-format='<?php echo (_('datetimeformat_moment')); ?>' class="mdl-textfield__input picker_datetime" id="timestamp" type="text" name="timestamp" value="<?php echo ($data['timestamp']) ? strftime(_('datetimeformat_php2'), intval($data['timestamp'])) : ''; ?>"/><span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></div>
	</div>
	</div><?php } ?><?php if (((false)) && ($data['subject::canEdit'] == 1)) { ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_subject" id="column_subject">
		<!-- Feld "subject": subject -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="subject"><?php echo(_('subject')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<div class="mdl-textfield mdl-js-textfield"><input onkeydown="
		if (event.keyCode == 13) {
			event.preventDefault();
			event.stopPropagation();
			tabNext(this);
			return false;
		}
	"  class="mdl-textfield__input"  type="text" name="subject"  value="<?php echo htmlentities($data['subject']); ?>"/><span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span></div>
	</div>
	</div><?php } ?><?php if ((!isset($_POST['cancel']))) { ?>
	<div class="mdl-cell mdl-cell--12-col mdl-grid grid-card column_directory" id="column_directory">
		<!-- Feld "directory": directory -->
	<div	class="mdl-cell mdl-cell--3-col mdl-cell--4-col-phone fop-form-label">
		<label for="directory"><?php echo(_('directory')); ?>: </label>
	</div>
	<div	class="mdl-cell mdl-cell--9-col mdl-cell--4-col-phone fop-form-content">
		<div style='display: flex; flex-direction: row; align-items: center; width: 100%;'><?php
	\Tables\Fop_mail_host_box_dir::renderEditform_wf_fop_mail_host_box_dir_email_edit_directoryAction($data['directory'], [], '');
?> &nbsp;	<?php if (\TablesRouter\Fop_mail_host_box_dir::createAccess()) { ?>  <a tabindex='-1' class='unimportant button' href="#" onclick='var p = $(this).parent(), id = "x"+Math.round(1000000*Math.random()); p.attr("id", id); window.open_over(<?php
		echo json_encode(\TablesRouter\Fop_mail_host_box_dir::createURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'directory\']'); ?>%26type=fop_mail_host_box_dir%26colinsert=directory%26el=" + encodeURIComponent(id) + "%26close%26insert_param=colvalue", "_blank", "width=739, height=395"); return false;'><i class="material-icons">add</i></a> <?php } ?> &nbsp;	<a tabindex='-1' class='unimportant button fop-ddt-search' href="#" onclick='var p = $(this).parent(), id = "x"+Math.round(1000000*Math.random()); p.attr("id", id); window.open_over(<?php
		echo json_encode(\TablesRouter\Fop_mail_host_box_dir::indexURL2([
			'popup' => true]
		)); ?> + "&from=<?php echo urlencode(\FOP\Util::getCurrentBaseurl()); ?>jscloser.php?action=popup%26ng=<?php echo urlencode('form[\'directory\']'); ?>%26type=fop_mail_host_box_dir%26colinsert=directory%26el=" + encodeURIComponent(id) + "%26insert_param=colvalue&select=fop_mail_host_box_dir", "_blank", "width=739, height=395"); return false;'><i class="material-icons">search</i></a>
	</div>
	</div>
	</div><?php } ?><?php
										\EasyEditor\FormFeature::pop();
										$features['Nachricht']['html'] = ob_get_contents();
										ob_end_clean();
									}
									

									uasort($features, function ($a, $b) {
										return strnatcmp($a['order'], $b['order']);
									});
									foreach ($features AS $feature) {
										\EasyEditor\FormFeature::render($feature);
									}
									?><script type='text/javascript'>
										$(function(){
											// bei Änderungen: prüfen, ob Form geändert wurde
											var formData = $('#cardform-wf_fop_mail_host_box_dir_email_edit').serialize();
											document.body.onbeforeunload = function () {
												if (formData != $('#cardform-wf_fop_mail_host_box_dir_email_edit').serialize()) {
													return 'Form data has changed - are you sure??';
												}
											};
											$('#cardform-wf_fop_mail_host_box_dir_email_edit').on('submit', function () {
												document.body.onbeforeunload = undefined;
											});
											<?php if ($upbar_collapsed) {
												?>$('#fop-bar-mainbutton').click();<?php
											} ?>
											$('#fop-bar-mainbutton').click(function () {
												setTimeout(function () {
													setCFF('upbar', 'collapsed', $('#fop-bar-container').is(':visible') ? 0 : 1);
												}, 440); /* perfect timing for fadeOut */
											});
										});
										
										function setCFF(id, key, value) {
											<?php if(!\FOP\User::getIsGuest()) { ?>
											$.get('FOP/Index/setCFF?form=wf%3Afop_mail_host_box_dir_email%3Aedit&subid=' + encodeURIComponent(id) + '&key=' + encodeURIComponent(key) + '&value=' + encodeURIComponent(value)).then(function () {
												if (key == 'reset') {
													location.reload();
												}
											});
											<?php } /* EditAccess */ ?>
										}
										function setCFFOrder(fids) {
											<?php if(!\FOP\User::getIsGuest()) { ?>
											$.get('FOP/Index/setCFFOrder?form=wf%3Afop_mail_host_box_dir_email%3Aedit&fids=' + encodeURIComponent(JSON.stringify(fids)));
											<?php } /* EditAccess */ ?>
										}
										$(function () {
											refreshTabHeaders($('#cardform-wf_fop_mail_host_box_dir_email_edit')); /* provided in js/form.js */
											// preselection
											if (location.hash.startsWith('#select:')) {
												$('[name="' + window.location.hash.slice(8) + '"]').focus().select();
											} else {
												$('#cardform-wf_fop_mail_host_box_dir_email_edit input[type!="hidden"],textarea,select[tabindex!="-1"]').not('.fop-disabled *').filter(':visible:first').focus().select();
											}
										});

										$(window).keydown(function(event) {
											 if (event.ctrlKey && String.fromCharCode(event.which).toLowerCase() == 's') {
												 event.preventDefault();
												 $('button[type=submit]').click();
												 return false;
											 }
										});

										
										$(document).on('keyup',function(evt) {
										   if (evt.keyCode == 27) {
												if (window.parent) {
													window.close(); // iframe:close
												} else {
													window.history.back();
												}
											}
												});
										
									</script>

							</form>
							

							</div>
							<div class="content" id="focus-supersearch">
							</div>
							<div class="content" id="~spacer"><?php if (!isset($_GET['popup'])) { ?><div style="padding-bottom: 10cm;"></div><?php } ?>
							</div>
						<?php if (!isset($_GET['popup'])) { ?>
					</div>
				</main>
				
			</div>
		<?php } else { ?></div><?php } ?>
<?php if (!isset($_GET['popup'])) { ?><div class='fop-seal'></div><?php } ?></body></html><?php
    // --- BLOCK: main-6 ---
    }
    
  }

  public static function emailDeleteAction($id) { 
    
    
    // --- BLOCK: access ---
    if(!(((\FOP\User::getIsLoggedIn())))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access-item-fop_mail_host_box_dir_email-view ---
    
		if (\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getIsLoggedIn()).') AND (COALESCE((SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('p0EDqmbn').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' '.qi('p0EDqmbn').' WHERE '.qi('p0EDqmbn').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('directory').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir_email').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() != 1) {
			throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: main ---
        
		$idlist = new \FOP\IDList($id);
		$i = 0;
		$j = ($idlist->count());
		foreach ($idlist->all() as $ids) {
   			$lastid = $ids;
			$i++;
			$mail = \FOP\Database::query('SELECT fop_mail_host_box_dir_email.uid, fop_mail_host_box_dir_email.boxid, fop_mail_host_box_dir.'.qi('ID').', fop_mail_host_box_dir.imap_name, (SELECT imap_name FROM fop_mail_host_box_dir WHERE '.qi('ID').' = fop_mail_host_box.trash_dir) AS trash FROM fop_mail_host_box_dir_email LEFT JOIN fop_mail_host_box ON fop_mail_host_box_dir_email.boxid = fop_mail_host_box.'.qi('ID').' LEFT JOIN fop_mail_host_box_dir ON fop_mail_host_box_dir_email.directory = fop_mail_host_box_dir.'.qi('ID').' WHERE fop_mail_host_box_dir_email.'.qi('ID').' = ' . \FOP\Database::quote($lastid))->fetch(\PDO::FETCH_ASSOC);
			if(isset($mail['trash'])) {
				$latestuid = \FOP\Database::query('SELECT latestuid FROM fop_imaplistener WHERE mailboxid = ' . \FOP\Database::quote($mail['boxid']) . ' AND directorystr = ' . \FOP\Database::quote($mail['imap_name']))->fetchColumn();
				if($mail['uid'] == $latestuid){
					\FOP\Database::query('UPDATE fop_imaplistener SET latestuid = ' . \FOP\Database::quote($uid) . ' WHERE mailboxid = ' . \FOP\Database::quote($mail['boxid']) . ' AND directorystr = ' . \FOP\Database::quote($mail['imap_name']));
				}
				if($mail['imap_name'] == $mail['trash']) {
					if($i == 1) $mbox = \Tables\Fop_mail_host_box_dir::imap_open($mail['boxid'], $mail['imap_name'], '');
					$msgno = imap_msgno($mbox, $mail['uid']);
					try {
						imap_delete($mbox, $msgno);
						\FOP\Database::query('DELETE FROM fop_mail_host_box_dir_email WHERE '.qi('ID').' = ' . \FOP\Database::quote($lastid));
						if($i == $j) {
							imap_close($mbox,CL_EXPUNGE); 
							header('Location: ' . \TablesRouter\Fop_mail_host_box_dir::viewURL2(['id' => $mail['ID']]).'#snack:Die%20Email%20wurde%20endgültig%20gelöscht');
							
						}
					} catch (Exception $e) {
						imap_close($mbox,CL_EXPUNGE);
						header('Location: ' . \TablesRouter\Fop_mail_host_box_dir::viewURL2(['id' => $mail['ID']]) . '#snack:Die%20EMail%20konnte%20nicht%20gelöscht%20werden!%20Bitte%20wenden%20Sie%20sich%20an%20den%20Administrator');
					}
				}else {
					try {
						\Tables\Fop_mail_host_box_dir_email::imap_move($mail['boxid'], $mail['uid'], $mail['imap_name'], $mail['trash'], $lastid);
						if($i == $j) {
							header('Location: ' . \TablesRouter\Fop_mail_host_box_dir::viewURL2(['id' => $mail['ID']]) . '#snack:Die%20Email%20wurde%20in%20den%20Papierkorb%20verschoben');
						}
					} catch (Exception $e){
						header('Location: ' . \TablesRouter\Fop_mail_host_box_dir::viewURL2(['id' => $mail['ID']]) . '#snack:Die%20EMail%20konnte%20nicht%20verschoben%20werden!%20Bitte%20wenden%20Sie%20sich%20an%20den%20Administrator');
					}
				}
			} else {
				header('Location: ' . \TablesRouter\Fop_mail_host_box_dir::viewURL2(['id' => $mail['ID']]) . '#snack:Bitte%20wählen%20Sie%20einen%20Ordner%20als%20Papierkorb%20aus');
			}
		}
	   
    
  }

  public static function emailSpamAction($id) { 
    
    
    // --- BLOCK: access ---
    if(!(((\FOP\User::getIsLoggedIn())))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access-item-fop_mail_host_box_dir_email-view ---
    
		if (\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getIsLoggedIn()).') AND (COALESCE((SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('p0EDqmbn').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' '.qi('p0EDqmbn').' WHERE '.qi('p0EDqmbn').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('directory').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir_email').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() != 1) {
			throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: main ---
     
		self::emailMove($id, 'Spam');	
	
    
  }

  public static function emailFlagAction($id) { 
    
    
    // --- BLOCK: access ---
    if(!(((\FOP\User::getIsLoggedIn())))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: access-item-fop_mail_host_box_dir_email-view ---
    
		if (\FOP\Database::query('SELECT ('.\FOP\Database::quote(\FOP\User::getIsLoggedIn()).') AND (COALESCE((SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('p0EDqmbn').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' '.qi('p0EDqmbn').' WHERE '.qi('p0EDqmbn').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('directory').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir_email').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id))->fetchColumn() != 1) {
			throw new \FOP\AccessDeniedException();
		}
	
    // --- BLOCK: main ---
     
		$idlist = new \FOP\IDList($id);
		$i = 0;
		$j = ($idlist->count());
		$mbox = NULL;		
		foreach ($idlist->all() as $ids) {
   			$lastid = $ids;
			$i++;	
			$mail = \FOP\Database::query('SELECT fop_mail_host_box_dir_email.uid, fop_mail_host_box_dir_email.boxid, fop_mail_host_box_dir.'.qi('ID').', fop_mail_host_box_dir.imap_name, fop_mail_host_box_dir_email.seen FROM fop_mail_host_box_dir_email LEFT JOIN fop_mail_host_box ON fop_mail_host_box_dir_email.boxid = fop_mail_host_box.'.qi('ID').' LEFT JOIN fop_mail_host_box_dir ON fop_mail_host_box_dir_email.directory = fop_mail_host_box_dir.'.qi('ID').' WHERE fop_mail_host_box_dir_email.'.qi('ID').' = ' . \FOP\Database::quote($lastid))->fetch(\PDO::FETCH_ASSOC);
		
		    	try {
				if (is_null($mbox)) $mbox = \Tables\Fop_mail_host_box_dir::imap_open($mail['boxid'], $mail['imap_name'], '');
				imap_clearflag_full($mbox, $mail['uid'], '\\Seen', ST_UID);
				\FOP\Database::query('UPDATE fop_mail_host_box_dir_email SET seen = FALSE WHERE uid = ' . \FOP\Database::quote($mail['uid']));
				if($i == $j) {
					imap_close($mbox,CL_EXPUNGE);
					header('Location: ' . \TablesRouter\Fop_mail_host_box_dir::viewURL2(['id' => $mail['ID']]) . '#snack:Die%20Email%20wurden%20als%20ungelesen%20Markiert');
				}
			} catch (Exception $e) {
				imap_close($mbox,CL_EXPUNGE);
				header('Location: ' . \TablesRouter\Fop_mail_host_box_dir::viewURL2(['id' => $mail['ID']]) . '#snack:Die%20EMails%20konnten%20nicht%20als%20ungelesen%20Markiert%20werden!%20Bitte%20wenden%20Sie%20sich%20an%20den%20Administrator');
				return;
			}
		}
	
    
  }

  public static function emailMove($id, $folder) { 
    
    
    // --- BLOCK: main ---
     
		//baduss
		$idlist = new \FOP\IDList($id);
		$i = 0;
		$j = ($idlist->count());	
		foreach ($idlist->all() as $ids) {
   			$lastid = $ids;
			$i++;	
			if ($folder === 'Spam') {
				$mail = \FOP\Database::query('SELECT fop_mail_host_box_dir_email.uid, fop_mail_host_box_dir_email.boxid, fop_mail_host_box_dir.'.qi('ID').', fop_mail_host_box_dir.imap_name, (SELECT imap_name FROM fop_mail_host_box_dir WHERE '.qi('ID').' = fop_mail_host_box.spam_dir) AS spam FROM fop_mail_host_box_dir_email LEFT JOIN fop_mail_host_box ON fop_mail_host_box_dir_email.boxid = fop_mail_host_box.'.qi('ID').' LEFT JOIN fop_mail_host_box_dir ON fop_mail_host_box_dir_email.directory = fop_mail_host_box_dir.'.qi('ID').' WHERE fop_mail_host_box_dir_email.'.qi('ID').' = ' . \FOP\Database::quote($lastid))->fetch(\PDO::FETCH_ASSOC);
				$folder = $mail['spam'];
			} else {
				$mail = \FOP\Database::query('SELECT fop_mail_host_box_dir_email.uid, fop_mail_host_box_dir_email.boxid, fop_mail_host_box_dir.'.qi('ID').', fop_mail_host_box_dir.imap_name FROM fop_mail_host_box_dir_email LEFT JOIN fop_mail_host_box ON fop_mail_host_box_dir_email.boxid = fop_mail_host_box.'.qi('ID').' LEFT JOIN fop_mail_host_box_dir ON fop_mail_host_box_dir_email.directory = fop_mail_host_box_dir.'.qi('ID').' WHERE fop_mail_host_box_dir_email.'.qi('ID').' = ' . \FOP\Database::quote($lastid))->fetch(\PDO::FETCH_ASSOC);
			}
			if (isset($folder)) {
				if ($mail['imap_name'] == $folder) {
					header('Location: ' . \TablesRouter\Fop_mail_host_box_dir::viewURL2(['id' => $mail['ID']]) . '#snack:Die%20Email%20liegt%20bereits%20im%%20Ordner%20' . $folder);
		 			return;
				} else {
		    			try {
						if (!($mbox = \Tables\Fop_mail_host_box_dir_email::imap_move($mail['boxid'], $mail['uid'], $mail['imap_name'], $folder, $lastid))) {		
							header('Location: ' . \TablesRouter\Fop_mail_host_box_dir::viewURL2(['id' => $mail['ID']]) . '#snack:Die%20konnte%20nicht%20verschoben%20werden!%20Dieser%20Imap%20Ordner%20existiert%20nicht!');
							die();
						}
						if($i == $j){ 
							imap_gc($mbox, IMAP_GC_ELT | IMAP_GC_ENV | IMAP_GC_TEXTS);
							imap_close($mbox,CL_EXPUNGE);
							header('Location: ' . \TablesRouter\Fop_mail_host_box_dir::viewURL2(['id' => $mail['ID']]) . '#snack:Die%20Email%20wurde%20in%20den%20Ordner%20' . $folder . '%20verschoben');
							die();
						}
					} catch (Exception $e) {
						imap_gc($mbox, IMAP_GC_ELT | IMAP_GC_ENV | IMAP_GC_TEXTS);
						imap_close($mbox,CL_EXPUNGE);
						header('Location: ' . \TablesRouter\Fop_mail_host_box_dir::viewURL2(['id' => $mail['ID']]) . '#snack:Die%20konnte%20nicht%20verschoben%20werden!%20Bitte%20wenden%20Sie%20sich%20an%20den%20Administrator');
						die();
					}
		 		}
			} else {
				header('Location: ' . \TablesRouter\Fop_mail_host_box_dir::viewURL2(['id' => $mail['ID']]) . '#snack:Bitte%20wählen%20Sie%20einen%20'.$folder.'%20Ordner%20aus');
				die();
			}
		}
	
    
  }

  public static function delete($id, $disregardPermissions = false ) { 
    
    
    // --- BLOCK: main ---
    
			$sql = 'SELECT ' . ($disregardPermissions ? 1 : '(FALSE) AND (COALESCE((SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('FTZDyDjf').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' '.qi('FTZDyDjf').' WHERE '.qi('FTZDyDjf').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('directory').' LIMIT 1), FALSE))') . ' FROM '.qi('fop_mail_host_box_dir_email').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id);
			if (\FOP\Database::query($sql)->fetchColumn() != 1) {
				return false;
			}
			
			$sql = 'DELETE FROM  '.qi('fop_mail_host_box_dir_email').'  WHERE '.qi('ID').' = ' . \FOP\Database::quote($id);
			$result = \FOP\Database::query($sql);
			
			return true;
	
    
  }

  public static function create($data, $disregardPermissions = false , $updateOnDuplicate = false ) { 
    
    
    // --- BLOCK: main ---
    
				$sql = 'INSERT INTO '.qi('fop_mail_host_box_dir_email').'(';
				
				$set = [];
				
					
					$set[qi('timestamp')] = \FOP\Database::quote($data['timestamp']);
					
				
					
					$set[qi('senderDisplay')] = \FOP\Database::quote($data['senderDisplay']);
					
				
					
					$set[qi('senderEmail')] = \FOP\Database::quote($data['senderEmail']);
					
				
					
					$set[qi('subject')] = \FOP\Database::quote($data['subject']);
					
				
					
					$set[qi('content')] = \FOP\Database::quote($data['content']);
					
				
					
					$set[qi('directory')] = \FOP\Database::quote($data['directory']);
					
				
					
					$set[qi('seen')] = \FOP\Database::quote($data['seen']);
					
				
					$set[qi('type')] = '' . \FOP\Database::quote($data['type']) . '';
					$set[qi('msgid')] = '' . intval($data['msgid']) . '';
					$set[qi('boxid')] = '' . intval($data['boxid']) . '';
					$set[qi('uid')] = '' . intval($data['uid']) . '';
				$id = 0;

				$sql = $sql . implode(', ', array_keys($set)) . ') VALUES (' . implode(', ', array_values($set)) . ')';
				if ($updateOnDuplicate){
					// TODO: Postgres ON CONFLICT(...) DO UPDATE SET ...
					$set2 = [];
					foreach ($set AS $k => $v) {
						array_push($set2, "$k = $v");
					}
					if (\FOP\Database::getDriver() == 'mysql') {
						$sql .= ' ON DUPLICATE KEY UPDATE ' . implode(', ', $set2);
					} else {
						
					}
				}

				try {
					\FOP\Database::query($sql);
					$id = \FOP\Database::getLastInsertId();
				} catch (\PDOException $e) {
					if ($e->errorInfo[1] == 1062) {
						throw new \FOP\AccessDeniedException('duplicateinsert');
					}
                    throw $e; // weiterwerfen
				}
				$data['fop-id'] = $id; // für Hooks
				
				return $id;

    
  }

  public static function view($id, $snippet = false , $ignoreAccess = false ) { 
    
    
    // --- BLOCK: main ---
    
		$sql = 'SELECT /* ID */ '.qi('ID').' AS '.qi('ID').',
									/* ID */ '.qi('fop_mail_host_box_dir_email').'.'.qi('ID').' AS '.qi('ID').',
									/* boxid */ '.qi('fop_mail_host_box_dir_email').'.'.qi('boxid').' AS '.qi('boxid').',
									/* content */ '.qi('fop_mail_host_box_dir_email').'.'.qi('content').' AS '.qi('content').',
									/* content::canEdit */ (FALSE) AS '.qi('content::canEdit').',
									/* directory */ '.qi('fop_mail_host_box_dir_email').'.'.qi('directory').' AS '.qi('directory').',
									/* directory::canView */ '.qi('ref:directory').'.'.qi('directory:canView').' AS '.qi('directory::canView').',
									/* directory::description */ '.qi('ref:directory').'.'.qi('directory:description').' AS '.qi('directory::description').',
									/* hasAttachments */ EXISTS (SELECT (TRUE) FROM '.qi('fop_mail_host_box_dir_email_attachment').' '.qi('exp0Y3r8').' WHERE '.qi('exp0Y3r8').'.'.qi('email').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('ID').' LIMIT 1) AS '.qi('hasAttachments').',
									/* msgid */ '.qi('fop_mail_host_box_dir_email').'.'.qi('msgid').' AS '.qi('msgid').',
									/* operation::create */ (FALSE) AND (COALESCE((SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('PXLLPZCy').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' '.qi('PXLLPZCy').' WHERE '.qi('PXLLPZCy').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('directory').' LIMIT 1), FALSE)) AS '.qi('operation::create').',
									/* operation::delete */ (FALSE) AND (COALESCE((SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('FTZDyDjf').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' '.qi('FTZDyDjf').' WHERE '.qi('FTZDyDjf').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('directory').' LIMIT 1), FALSE)) AS '.qi('operation::delete').',
									/* operation::edit */ (COALESCE((SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('KcSSV43E').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' '.qi('KcSSV43E').' WHERE '.qi('KcSSV43E').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('directory').' LIMIT 1), FALSE)) AS '.qi('operation::edit').',
									/* operation::index */ ' . (!\FOP\User::getIsGuest() ? 1 : 0) . ' AS '.qi('operation::index').',
									/* operation::view */ ('.\FOP\Database::quote(\FOP\User::getIsLoggedIn()).') AND (COALESCE((SELECT (COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('p0EDqmbn').'.'.qi('mailbox').' LIMIT 1), FALSE)) FROM '.qi('fop_mail_host_box_dir').' '.qi('p0EDqmbn').' WHERE '.qi('p0EDqmbn').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('directory').' LIMIT 1), FALSE)) AS '.qi('operation::view').',
									/* recipient */ (SELECT (CONCAT('.qi('vruMkJVV').'.'.qi('display').', \' <\', '.qi('vruMkJVV').'.'.qi('address').', \'>\')) FROM '.qi('fop_mail_host_box_dir_email_recipient').' '.qi('vruMkJVV').' WHERE '.qi('vruMkJVV').'.'.qi('email').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('ID').' LIMIT 1) AS '.qi('recipient').',
									/* seen */ '.qi('fop_mail_host_box_dir_email').'.'.qi('seen').' AS '.qi('seen').',
									/* seen::canEdit */ (FALSE) AS '.qi('seen::canEdit').',
									/* senderDisplay */ '.qi('fop_mail_host_box_dir_email').'.'.qi('senderDisplay').' AS '.qi('senderDisplay').',
									/* senderDisplay::canEdit */ (FALSE) AS '.qi('senderDisplay::canEdit').',
									/* senderEmail */ '.qi('fop_mail_host_box_dir_email').'.'.qi('senderEmail').' AS '.qi('senderEmail').',
									/* senderEmail::canEdit */ (FALSE) AS '.qi('senderEmail::canEdit').',
									/* subject */ '.qi('fop_mail_host_box_dir_email').'.'.qi('subject').' AS '.qi('subject').',
									/* subject::canEdit */ (FALSE) AS '.qi('subject::canEdit').',
									/* timestamp */ '.qi('fop_mail_host_box_dir_email').'.'.qi('timestamp').' AS '.qi('timestamp').',
									/* timestamp::canEdit */ (FALSE) AS '.qi('timestamp::canEdit').',
									/* type */ '.qi('fop_mail_host_box_dir_email').'.'.qi('type').' AS '.qi('type').',
									/* uid */ '.qi('fop_mail_host_box_dir_email').'.'.qi('uid').' AS '.qi('uid').',
									1
								FROM '.qi('fop_mail_host_box_dir_email').' '.qi('fop_mail_host_box_dir_email').'
								LEFT JOIN (SELECT '.qi('ID').' AS '.qi('directory:ID').', CONCAT('.qi('fop_mail_host_box_dir').'.'.qi('name').', \' - \', (SELECT ('.qi('tcayeuX5').'.'.qi('from_address').') FROM '.qi('fop_mail_host_box').' '.qi('tcayeuX5').' WHERE '.qi('tcayeuX5').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir').'.'.qi('mailbox').' LIMIT 1)) AS '.qi('directory:description').', ((COALESCE((SELECT (CASE WHEN FALSE THEN TRUE ELSE NOT (('.qi('1IDxgk3w').'.'.qi('fopuser').') <> ('.\FOP\Database::sessionVarSQL('user').')) END) FROM '.qi('fop_mail_host_box').' '.qi('1IDxgk3w').' WHERE '.qi('1IDxgk3w').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir').'.'.qi('mailbox').' LIMIT 1), FALSE))) AS '.qi('directory:canView').' FROM '.qi('fop_mail_host_box_dir').') '.qi('ref:directory').' ON '.qi('ref:directory').'.'.qi('directory:ID').' = '.qi('fop_mail_host_box_dir_email').'.'.qi('directory').'
								WHERE ('.qi('ID').' = ' . \FOP\Database::quote($id) . ')';
		$result = \FOP\Database::query($sql);
		if (!$row = $result->fetch(\PDO::FETCH_ASSOC)) {
			throw new \FOP\AccessDeniedException('notfoundread');
		} else if (!$ignoreAccess && !$row['operation::view']) {
			throw new \FOP\AccessDeniedException('accessdeniedread');
		}
		
		$row['timestamp'] = intval($row['timestamp']);
		$row['senderEmail'] = \FOP\Sanitizers::a_text($row['senderEmail']);
		$row['directory'] = \FOP\Sanitizers::null_converter($row['directory']);
		$row['seen'] = \FOP\Util::BoolSanitizer($row['seen']);
		

		if($snippet){
			$row['timestamp'] = (($row['timestamp']) ? strftime(_('datetimeformat_php2'), intval($row['timestamp'])) : '');
			$row['senderDisplay'] = ($row['senderDisplay']);
			$row['senderEmail'] = ($row['senderEmail']);
			$row['recipient'] = ($row['recipient']);
			$row['hasAttachments'] = (\Types\FopemailhasAttachments::toIcon($row['hasAttachments']));
			$row['subject'] = ($row['subject']);
			$row['content'] = (mb_substr(preg_replace('/[ \t\r\n]+/', ' ', strip_tags(preg_replace('/<style.*?\/style>/s', '', html_entity_decode($row['content'])))), 0, 20) . (strlen($row['content']) >= 20 ? '...' : ''));
			$row['directory'] = (
  \FOP\Database::query('SELECT CONCAT('.qi('fop_mail_host_box_dir').'.'.qi('name').', \' - \', (SELECT ('.qi('tcayeuX5').'.'.qi('from_address').') FROM '.qi('fop_mail_host_box').' '.qi('tcayeuX5').' WHERE '.qi('tcayeuX5').'.'.qi('ID').' = '.qi('fop_mail_host_box_dir').'.'.qi('mailbox').' LIMIT 1)) AS description FROM '.qi('fop_mail_host_box_dir').' WHERE '.qi('ID').' = ' . \FOP\Database::quote($row['directory']))->fetchColumn() ?: _('')
);
			$row['seen'] = ($row['seen']);
			
		}


		return $row;

    
  }

  public static function searchOptionsfop_mail_host_box_dir_email_thread_email_deletecascadeAction($value, $str, $deps) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Fop_mail_host_box_dir_email::getItems($deps, $value, $str); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	return $items;
	
    
  }

  public static function searchOptionsfop_mail_host_box_dir_email_recipient_email_deletecascadeAction($value, $str, $deps) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Fop_mail_host_box_dir_email::getItems($deps, $value, $str); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	return $items;
	
    
  }

  public static function searchOptionsfop_mail_host_box_dir_email_attachment_email_deletecascadeAction($value, $str, $deps) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Fop_mail_host_box_dir_email::getItems($deps, $value, $str); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	return $items;
	
    
  }

  public static function searchOptionsform_wf_fop_mail_host_box_dir_email_thread_create_emailAction($value, $str, $deps) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Fop_mail_host_box_dir_email::getItems($deps, $value, $str); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	return $items;
	
    
  }

  public static function searchOptionsform_wf_fop_mail_host_box_dir_email_recipient_create_emailAction($value, $str, $deps) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Fop_mail_host_box_dir_email::getItems($deps, $value, $str); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	return $items;
	
    
  }

  public static function searchOptionsform_wf_fop_mail_host_box_dir_email_attachment_create_emailAction($value, $str, $deps) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Fop_mail_host_box_dir_email::getItems($deps, $value, $str); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	return $items;
	
    
  }

  public static function searchOptionsform_wf_fop_mail_host_box_dir_email_thread_edit_emailAction($value, $str, $deps) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Fop_mail_host_box_dir_email::getItems($deps, $value, $str); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	return $items;
	
    
  }

  public static function searchOptionsform_wf_fop_mail_host_box_dir_email_recipient_edit_emailAction($value, $str, $deps) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Fop_mail_host_box_dir_email::getItems($deps, $value, $str); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	return $items;
	
    
  }

  public static function searchOptionsform_wf_fop_mail_host_box_dir_email_attachment_edit_emailAction($value, $str, $deps) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Fop_mail_host_box_dir_email::getItems($deps, $value, $str); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	return $items;
	
    
  }

  public static function sanitizeDefaults(&$data, $sanitizeForForms, $refcol = null , $parentdata = null ) { 
    
    
    // --- BLOCK: main ---
    
		$virginData = self::getDefaults();
		// column: content
		
		// column: directory
			if (!$data['directory']) {
				// replace forbidden NULL values
				$items = \Types\Fop_mail_host_box_dir::getItems([], null);
				$best = -INF;
				foreach ($items as $item) /* TODO: InputFieldLoadCondition: if (!$condition || $item[$condition]) */ {
					if ($item['priority'] > $best) {
						$data['directory'] = $item['ID'];
						$best = $item['priority'];
					}
				}
			}
		
		// column: seen
		
		// column: senderDisplay
		
		// column: senderEmail
		
		// column: subject
		
		// column: timestamp
		
		if ($sanitizeForForms) {
			
			$data['timestamp'] = intval($data['timestamp']);
			$data['senderEmail'] = \FOP\Sanitizers::a_text($data['senderEmail']);
			$data['directory'] = \FOP\Sanitizers::null_converter($data['directory']);
			$data['seen'] = \FOP\Util::BoolSanitizer($data['seen']);
		}
	
    
  }

  public static function edit($id, $data, $ignoreUniqueConstraints = false , $disregardPermissions = false ) { 
    
    
    // --- BLOCK: main ---
    
				
				$set = [];
				
					if ($disregardPermissions || ((false)))
					
					if (array_key_exists('timestamp', $data)) {
						array_push($set, qi('timestamp').' = ' . \FOP\Database::quote($data['timestamp']));
					}
				
					if ($disregardPermissions || ((false)))
					
					if (array_key_exists('senderDisplay', $data)) {
						array_push($set, qi('senderDisplay').' = ' . \FOP\Database::quote($data['senderDisplay']));
					}
				
					if ($disregardPermissions || ((false)))
					
					if (array_key_exists('senderEmail', $data)) {
						array_push($set, qi('senderEmail').' = ' . \FOP\Database::quote($data['senderEmail']));
					}
				
					if ($disregardPermissions || ((false)))
					
					if (array_key_exists('subject', $data)) {
						array_push($set, qi('subject').' = ' . \FOP\Database::quote($data['subject']));
					}
				
					if ($disregardPermissions || ((false)))
					
					if (array_key_exists('content', $data)) {
						array_push($set, qi('content').' = ' . \FOP\Database::quote($data['content']));
					}
				
					
					if (array_key_exists('directory', $data)) {
						array_push($set, qi('directory').' = ' . \FOP\Database::quote($data['directory']));
					}
				
					if ($disregardPermissions || ((false)))
					
					if (array_key_exists('seen', $data)) {
						array_push($set, qi('seen').' = ' . \FOP\Database::quote($data['seen']));
					}
				;
				
				if (count($set)) {
					try {
						\FOP\Database::query('UPDATE '.qi('fop_mail_host_box_dir_email').' SET ' . implode(', ', $set) . ' WHERE '.qi('ID').' = ' . \FOP\Database::quote($id));
						if (isset($data['ID'])) {
							$id = $data['ID'];
						}
					} catch (\PDOException $e) {
						if ($e->errorInfo[1] == 1062) {
							if ($ignoreUniqueConstraints) {
								return false;
							}
							throw new \FOP\AccessDeniedException('duplicateupdate');
						}
						throw $e; // weiterwerfen
					}
				}
				$data['fop-id'] = $id; // für Hooks
				
				return true;

    
  }

  public static function renderEditfop_mail_host_box_dir_email_thread_email_deletecascadeAction($value, $deps, $condition, $fop_field_name = null ) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Fop_mail_host_box_dir_email::getItems($deps, $value); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	?>
<div class="mdlext-selectfield mdlext-js-selectfield" style="max-width:  300px;">
	<select tabindex='-1' class="selectdropdown mdlext-selectfield__select" name="value_fop_mail_host_box_dir_email_thread_email" data-default="<?php echo htmlentities($value ?: 0); ?>" style="color: rgba(0,0,0,0);" onchange="
		var val = this.value;
		if (val == '_more') {
			$(this.parentNode.parentNode).find('.fop-ddt-search').click();
			return;
		}
		this.nextElementSibling.value = this.options[this.selectedIndex].text;
		this.nextElementSibling.focus();
		this.nextElementSibling.select();
		$(this.parentElement).find('.fop-remove-after-change').remove();
		this.value = val;

		var model = this.getAttribute('xng-model');
		if (model) {
			$(this).scope().$eval(model + '=' + JSON.stringify(this.value));
			$(this).scope().$apply();
		}
	">
		<?php $text = ''; ?><?php
			$isLong = count($items) && $items[count($items) - 1]['ID'] == '_more';
			foreach ($items AS $item) if (!$condition || $item[$condition]) {
				?><option value="<?php echo htmlentities($item['ID'])?>" <?php
					if ($item['ID'] == $value) {
						// Wert ist gewählt
						echo "selected";
						$text = $item['description'];
						if (isset($item['forbidden'])) {
							$isForbidden = true;
							echo ' class="fop-remove-after-change"';
						}
					}?>><?php echo htmlentities($item['description']); ?></option>
		<?php
			}
		?>
	</select>
	<input class="mdl-textfield__input" value="<?php echo htmlentities($text); ?>" style="position: absolute; top: 20px; left: 4px; width: calc(100% - 32px);" type="text" data-lastsearch="" onkeydown="
		if (event.keyCode == 13) {
			event.preventDefault();
			event.stopPropagation();
			// ENTER: erstbestes passendes Element zuweisen
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				if (this.parentNode.firstElementChild.options[x].text.includes(this.value)) { // Text (z.B. EAN) kommt darin vor:
					this.parentNode.firstElementChild.selectedIndex = x;
					this.value = this.parentNode.firstElementChild.options[x].text;
					var model = this.parentNode.firstElementChild.getAttribute('xng-model');
					if (model) {
						$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
						$(this).scope().$apply();
					}
					$(this.parentElement).find('.fop-remove-after-change').remove();
					tabNext(this);
					return false;
				}
			}
			return false;
		}
		if (!this.list) {
			var list = document.createElement('datalist');
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				var option = document.createElement('option');
				option.value = this.parentNode.firstElementChild.options[x].text;
				list.appendChild(option);
			}
			this.parentNode.appendChild(list);
			list.id = 'datalist' + String(Math.random()).substr(2);
			this.setAttribute('list', list.id);
			this.setAttribute('onkeydown', this.getAttribute('onchange'));
			this.list = list;
		}
	" oninput="
		for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
			if (this.value == this.parentNode.firstElementChild.options[x].text) {
				var model = this.parentNode.firstElementChild.getAttribute('xng-model');
				if (model) {
					$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
					$(this).scope().$apply();
				}
				this.parentNode.firstElementChild.selectedIndex = x;
				$(this.parentElement).find('.fop-remove-after-change').remove();
			}
		}
		<?php if ($isLong) { ?>
			// Ajax+SQL mit LIKE-Query LIMIT
			var self = this;
			function updateSuggestions() {
				var value = self.value; // save in variable to keep stable during ajax
				if (value == self.getAttribute('data-lastsearch') || value == self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].text) {
					$(self).removeClass('busy');
					$(self).removeClass('busy-dirty');
					return;
				}
				$(self).addClass('busy');
				$.get('Tables/Fop_mail_host_box_dir_email/searchOptionsfop_mail_host_box_dir_email_thread_email_deletecascade?value=' + encodeURIComponent(self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].value) + '&deps=' + <?php echo htmlentities(json_encode(urlencode(json_encode($deps)))); ?> + '&str=' + encodeURIComponent(value)).then(function (result) {
					self.setAttribute('data-lastsearch', value);
					// Options eintragen
					$(self.parentNode.firstElementChild).empty();
					if (self.list) {
						$(self.list).empty();
					} else {
						var list = document.createElement('datalist');
						self.parentNode.appendChild(list);
						list.id = 'datalist' + String(Math.random()).substr(2);
						self.setAttribute('list', list.id);
						self.list = list;
					}
					for (var i = 0; i < result.length; i++) {
						var option = document.createElement('option');
						option.value = result[i].ID;
						option.text = result[i].description;
						self.parentNode.firstElementChild.appendChild(option);
						if (option.textContent == value) {
							option.selected = i;
							$(self.parentElement).find('.fop-remove-after-change').remove();
						}

						var option = document.createElement('option');
						option.value = result[i].description;
						self.list.appendChild(option);
					}
					/* reset busy flag */
					$(self).removeClass('busy');
					if ($(self).hasClass('busy-dirty')) {
						$(self).removeClass('busy-dirty');
						updateSuggestions(); //
					}
				});
			};
			if ($(self).hasClass('busy')) {
				// busy: busy->dirty
				$(self).addClass('busy-dirty');
				$(self).removeClass('busy');
				// mark as busy-dirty; updateSuggestions will trigger itself again
			} else if ($(self).hasClass('busy-dirty')) {
				// already dirty - we can save one reload cycle
			} else {
				// no request pending yet
				updateSuggestions();
			}
		<?php } ?>
	" onclick="this.focus(); if (this.value == <?php echo (_('pSelect'));?>) this.select();">
	<?php
		if (count($items) == 0) {
			?><span class="mdl-textfield__error fop-form-error" style="visibility: visible;"><?php echo(_('no_dropdown_values')) ?></span><?php
		}
	?>
	<?php if (isset($isForbidden) && $isForbidden) {
			?><span class="mdl-textfield__error fop-form-error fop-remove-after-change" style="visibility: visible;"><?php echo(_('invalid')) ?></span><?php
	} ?>
	 <span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span>
</div>

<?php

    
  }

  public static function renderEditfop_mail_host_box_dir_email_recipient_email_deletecascadeAction($value, $deps, $condition, $fop_field_name = null ) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Fop_mail_host_box_dir_email::getItems($deps, $value); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	?>
<div class="mdlext-selectfield mdlext-js-selectfield" style="max-width:  300px;">
	<select tabindex='-1' class="selectdropdown mdlext-selectfield__select" name="value_fop_mail_host_box_dir_email_recipient_email" data-default="<?php echo htmlentities($value ?: 0); ?>" style="color: rgba(0,0,0,0);" onchange="
		var val = this.value;
		if (val == '_more') {
			$(this.parentNode.parentNode).find('.fop-ddt-search').click();
			return;
		}
		this.nextElementSibling.value = this.options[this.selectedIndex].text;
		this.nextElementSibling.focus();
		this.nextElementSibling.select();
		$(this.parentElement).find('.fop-remove-after-change').remove();
		this.value = val;

		var model = this.getAttribute('xng-model');
		if (model) {
			$(this).scope().$eval(model + '=' + JSON.stringify(this.value));
			$(this).scope().$apply();
		}
	">
		<?php $text = ''; ?><?php
			$isLong = count($items) && $items[count($items) - 1]['ID'] == '_more';
			foreach ($items AS $item) if (!$condition || $item[$condition]) {
				?><option value="<?php echo htmlentities($item['ID'])?>" <?php
					if ($item['ID'] == $value) {
						// Wert ist gewählt
						echo "selected";
						$text = $item['description'];
						if (isset($item['forbidden'])) {
							$isForbidden = true;
							echo ' class="fop-remove-after-change"';
						}
					}?>><?php echo htmlentities($item['description']); ?></option>
		<?php
			}
		?>
	</select>
	<input class="mdl-textfield__input" value="<?php echo htmlentities($text); ?>" style="position: absolute; top: 20px; left: 4px; width: calc(100% - 32px);" type="text" data-lastsearch="" onkeydown="
		if (event.keyCode == 13) {
			event.preventDefault();
			event.stopPropagation();
			// ENTER: erstbestes passendes Element zuweisen
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				if (this.parentNode.firstElementChild.options[x].text.includes(this.value)) { // Text (z.B. EAN) kommt darin vor:
					this.parentNode.firstElementChild.selectedIndex = x;
					this.value = this.parentNode.firstElementChild.options[x].text;
					var model = this.parentNode.firstElementChild.getAttribute('xng-model');
					if (model) {
						$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
						$(this).scope().$apply();
					}
					$(this.parentElement).find('.fop-remove-after-change').remove();
					tabNext(this);
					return false;
				}
			}
			return false;
		}
		if (!this.list) {
			var list = document.createElement('datalist');
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				var option = document.createElement('option');
				option.value = this.parentNode.firstElementChild.options[x].text;
				list.appendChild(option);
			}
			this.parentNode.appendChild(list);
			list.id = 'datalist' + String(Math.random()).substr(2);
			this.setAttribute('list', list.id);
			this.setAttribute('onkeydown', this.getAttribute('onchange'));
			this.list = list;
		}
	" oninput="
		for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
			if (this.value == this.parentNode.firstElementChild.options[x].text) {
				var model = this.parentNode.firstElementChild.getAttribute('xng-model');
				if (model) {
					$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
					$(this).scope().$apply();
				}
				this.parentNode.firstElementChild.selectedIndex = x;
				$(this.parentElement).find('.fop-remove-after-change').remove();
			}
		}
		<?php if ($isLong) { ?>
			// Ajax+SQL mit LIKE-Query LIMIT
			var self = this;
			function updateSuggestions() {
				var value = self.value; // save in variable to keep stable during ajax
				if (value == self.getAttribute('data-lastsearch') || value == self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].text) {
					$(self).removeClass('busy');
					$(self).removeClass('busy-dirty');
					return;
				}
				$(self).addClass('busy');
				$.get('Tables/Fop_mail_host_box_dir_email/searchOptionsfop_mail_host_box_dir_email_recipient_email_deletecascade?value=' + encodeURIComponent(self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].value) + '&deps=' + <?php echo htmlentities(json_encode(urlencode(json_encode($deps)))); ?> + '&str=' + encodeURIComponent(value)).then(function (result) {
					self.setAttribute('data-lastsearch', value);
					// Options eintragen
					$(self.parentNode.firstElementChild).empty();
					if (self.list) {
						$(self.list).empty();
					} else {
						var list = document.createElement('datalist');
						self.parentNode.appendChild(list);
						list.id = 'datalist' + String(Math.random()).substr(2);
						self.setAttribute('list', list.id);
						self.list = list;
					}
					for (var i = 0; i < result.length; i++) {
						var option = document.createElement('option');
						option.value = result[i].ID;
						option.text = result[i].description;
						self.parentNode.firstElementChild.appendChild(option);
						if (option.textContent == value) {
							option.selected = i;
							$(self.parentElement).find('.fop-remove-after-change').remove();
						}

						var option = document.createElement('option');
						option.value = result[i].description;
						self.list.appendChild(option);
					}
					/* reset busy flag */
					$(self).removeClass('busy');
					if ($(self).hasClass('busy-dirty')) {
						$(self).removeClass('busy-dirty');
						updateSuggestions(); //
					}
				});
			};
			if ($(self).hasClass('busy')) {
				// busy: busy->dirty
				$(self).addClass('busy-dirty');
				$(self).removeClass('busy');
				// mark as busy-dirty; updateSuggestions will trigger itself again
			} else if ($(self).hasClass('busy-dirty')) {
				// already dirty - we can save one reload cycle
			} else {
				// no request pending yet
				updateSuggestions();
			}
		<?php } ?>
	" onclick="this.focus(); if (this.value == <?php echo (_('pSelect'));?>) this.select();">
	<?php
		if (count($items) == 0) {
			?><span class="mdl-textfield__error fop-form-error" style="visibility: visible;"><?php echo(_('no_dropdown_values')) ?></span><?php
		}
	?>
	<?php if (isset($isForbidden) && $isForbidden) {
			?><span class="mdl-textfield__error fop-form-error fop-remove-after-change" style="visibility: visible;"><?php echo(_('invalid')) ?></span><?php
	} ?>
	 <span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span>
</div>

<?php

    
  }

  public static function renderEditfop_mail_host_box_dir_email_attachment_email_deletecascadeAction($value, $deps, $condition, $fop_field_name = null ) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Fop_mail_host_box_dir_email::getItems($deps, $value); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	?>
<div class="mdlext-selectfield mdlext-js-selectfield" style="max-width:  300px;">
	<select tabindex='-1' class="selectdropdown mdlext-selectfield__select" name="value_fop_mail_host_box_dir_email_attachment_email" data-default="<?php echo htmlentities($value ?: 0); ?>" style="color: rgba(0,0,0,0);" onchange="
		var val = this.value;
		if (val == '_more') {
			$(this.parentNode.parentNode).find('.fop-ddt-search').click();
			return;
		}
		this.nextElementSibling.value = this.options[this.selectedIndex].text;
		this.nextElementSibling.focus();
		this.nextElementSibling.select();
		$(this.parentElement).find('.fop-remove-after-change').remove();
		this.value = val;

		var model = this.getAttribute('xng-model');
		if (model) {
			$(this).scope().$eval(model + '=' + JSON.stringify(this.value));
			$(this).scope().$apply();
		}
	">
		<?php $text = ''; ?><?php
			$isLong = count($items) && $items[count($items) - 1]['ID'] == '_more';
			foreach ($items AS $item) if (!$condition || $item[$condition]) {
				?><option value="<?php echo htmlentities($item['ID'])?>" <?php
					if ($item['ID'] == $value) {
						// Wert ist gewählt
						echo "selected";
						$text = $item['description'];
						if (isset($item['forbidden'])) {
							$isForbidden = true;
							echo ' class="fop-remove-after-change"';
						}
					}?>><?php echo htmlentities($item['description']); ?></option>
		<?php
			}
		?>
	</select>
	<input class="mdl-textfield__input" value="<?php echo htmlentities($text); ?>" style="position: absolute; top: 20px; left: 4px; width: calc(100% - 32px);" type="text" data-lastsearch="" onkeydown="
		if (event.keyCode == 13) {
			event.preventDefault();
			event.stopPropagation();
			// ENTER: erstbestes passendes Element zuweisen
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				if (this.parentNode.firstElementChild.options[x].text.includes(this.value)) { // Text (z.B. EAN) kommt darin vor:
					this.parentNode.firstElementChild.selectedIndex = x;
					this.value = this.parentNode.firstElementChild.options[x].text;
					var model = this.parentNode.firstElementChild.getAttribute('xng-model');
					if (model) {
						$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
						$(this).scope().$apply();
					}
					$(this.parentElement).find('.fop-remove-after-change').remove();
					tabNext(this);
					return false;
				}
			}
			return false;
		}
		if (!this.list) {
			var list = document.createElement('datalist');
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				var option = document.createElement('option');
				option.value = this.parentNode.firstElementChild.options[x].text;
				list.appendChild(option);
			}
			this.parentNode.appendChild(list);
			list.id = 'datalist' + String(Math.random()).substr(2);
			this.setAttribute('list', list.id);
			this.setAttribute('onkeydown', this.getAttribute('onchange'));
			this.list = list;
		}
	" oninput="
		for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
			if (this.value == this.parentNode.firstElementChild.options[x].text) {
				var model = this.parentNode.firstElementChild.getAttribute('xng-model');
				if (model) {
					$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
					$(this).scope().$apply();
				}
				this.parentNode.firstElementChild.selectedIndex = x;
				$(this.parentElement).find('.fop-remove-after-change').remove();
			}
		}
		<?php if ($isLong) { ?>
			// Ajax+SQL mit LIKE-Query LIMIT
			var self = this;
			function updateSuggestions() {
				var value = self.value; // save in variable to keep stable during ajax
				if (value == self.getAttribute('data-lastsearch') || value == self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].text) {
					$(self).removeClass('busy');
					$(self).removeClass('busy-dirty');
					return;
				}
				$(self).addClass('busy');
				$.get('Tables/Fop_mail_host_box_dir_email/searchOptionsfop_mail_host_box_dir_email_attachment_email_deletecascade?value=' + encodeURIComponent(self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].value) + '&deps=' + <?php echo htmlentities(json_encode(urlencode(json_encode($deps)))); ?> + '&str=' + encodeURIComponent(value)).then(function (result) {
					self.setAttribute('data-lastsearch', value);
					// Options eintragen
					$(self.parentNode.firstElementChild).empty();
					if (self.list) {
						$(self.list).empty();
					} else {
						var list = document.createElement('datalist');
						self.parentNode.appendChild(list);
						list.id = 'datalist' + String(Math.random()).substr(2);
						self.setAttribute('list', list.id);
						self.list = list;
					}
					for (var i = 0; i < result.length; i++) {
						var option = document.createElement('option');
						option.value = result[i].ID;
						option.text = result[i].description;
						self.parentNode.firstElementChild.appendChild(option);
						if (option.textContent == value) {
							option.selected = i;
							$(self.parentElement).find('.fop-remove-after-change').remove();
						}

						var option = document.createElement('option');
						option.value = result[i].description;
						self.list.appendChild(option);
					}
					/* reset busy flag */
					$(self).removeClass('busy');
					if ($(self).hasClass('busy-dirty')) {
						$(self).removeClass('busy-dirty');
						updateSuggestions(); //
					}
				});
			};
			if ($(self).hasClass('busy')) {
				// busy: busy->dirty
				$(self).addClass('busy-dirty');
				$(self).removeClass('busy');
				// mark as busy-dirty; updateSuggestions will trigger itself again
			} else if ($(self).hasClass('busy-dirty')) {
				// already dirty - we can save one reload cycle
			} else {
				// no request pending yet
				updateSuggestions();
			}
		<?php } ?>
	" onclick="this.focus(); if (this.value == <?php echo (_('pSelect'));?>) this.select();">
	<?php
		if (count($items) == 0) {
			?><span class="mdl-textfield__error fop-form-error" style="visibility: visible;"><?php echo(_('no_dropdown_values')) ?></span><?php
		}
	?>
	<?php if (isset($isForbidden) && $isForbidden) {
			?><span class="mdl-textfield__error fop-form-error fop-remove-after-change" style="visibility: visible;"><?php echo(_('invalid')) ?></span><?php
	} ?>
	 <span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span>
</div>

<?php

    
  }

  public static function renderEditform_wf_fop_mail_host_box_dir_email_thread_create_emailAction($value, $deps, $condition, $fop_field_name = null ) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Fop_mail_host_box_dir_email::getItems($deps, $value); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	?>
<div class="mdlext-selectfield mdlext-js-selectfield" style="max-width:  300px;">
	<select tabindex='-1' xng-model='form[&apos;email&apos;]' class="selectdropdown mdlext-selectfield__select" name="email" data-default="<?php echo htmlentities($value ?: 0); ?>" style="color: rgba(0,0,0,0);" onchange="
		var val = this.value;
		if (val == '_more') {
			$(this.parentNode.parentNode).find('.fop-ddt-search').click();
			return;
		}
		this.nextElementSibling.value = this.options[this.selectedIndex].text;
		this.nextElementSibling.focus();
		this.nextElementSibling.select();
		$(this.parentElement).find('.fop-remove-after-change').remove();
		this.value = val;

		var model = this.getAttribute('xng-model');
		if (model) {
			$(this).scope().$eval(model + '=' + JSON.stringify(this.value));
			$(this).scope().$apply();
		}
	">
		<?php $text = ''; ?><?php
			$isLong = count($items) && $items[count($items) - 1]['ID'] == '_more';
			foreach ($items AS $item) if (!$condition || $item[$condition]) {
				?><option value="<?php echo htmlentities($item['ID'])?>" <?php
					if ($item['ID'] == $value) {
						// Wert ist gewählt
						echo "selected";
						$text = $item['description'];
						if (isset($item['forbidden'])) {
							$isForbidden = true;
							echo ' class="fop-remove-after-change"';
						}
					}?>><?php echo htmlentities($item['description']); ?></option>
		<?php
			}
		?>
	</select>
	<input ng-trigger-change='form[&apos;email&apos;]' fop-type='Fop_mail_host_box_dir_email' class="mdl-textfield__input" value="<?php echo htmlentities($text); ?>" style="position: absolute; top: 20px; left: 4px; width: calc(100% - 32px);" type="text" data-lastsearch="" onkeydown="
		if (event.keyCode == 13) {
			event.preventDefault();
			event.stopPropagation();
			// ENTER: erstbestes passendes Element zuweisen
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				if (this.parentNode.firstElementChild.options[x].text.includes(this.value)) { // Text (z.B. EAN) kommt darin vor:
					this.parentNode.firstElementChild.selectedIndex = x;
					this.value = this.parentNode.firstElementChild.options[x].text;
					var model = this.parentNode.firstElementChild.getAttribute('xng-model');
					if (model) {
						$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
						$(this).scope().$apply();
					}
					$(this.parentElement).find('.fop-remove-after-change').remove();
					tabNext(this);
					return false;
				}
			}
			return false;
		}
		if (!this.list) {
			var list = document.createElement('datalist');
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				var option = document.createElement('option');
				option.value = this.parentNode.firstElementChild.options[x].text;
				list.appendChild(option);
			}
			this.parentNode.appendChild(list);
			list.id = 'datalist' + String(Math.random()).substr(2);
			this.setAttribute('list', list.id);
			this.setAttribute('onkeydown', this.getAttribute('onchange'));
			this.list = list;
		}
	" oninput="
		for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
			if (this.value == this.parentNode.firstElementChild.options[x].text) {
				var model = this.parentNode.firstElementChild.getAttribute('xng-model');
				if (model) {
					$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
					$(this).scope().$apply();
				}
				this.parentNode.firstElementChild.selectedIndex = x;
				$(this.parentElement).find('.fop-remove-after-change').remove();
			}
		}
		<?php if ($isLong) { ?>
			// Ajax+SQL mit LIKE-Query LIMIT
			var self = this;
			function updateSuggestions() {
				var value = self.value; // save in variable to keep stable during ajax
				if (value == self.getAttribute('data-lastsearch') || value == self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].text) {
					$(self).removeClass('busy');
					$(self).removeClass('busy-dirty');
					return;
				}
				$(self).addClass('busy');
				$.get('Tables/Fop_mail_host_box_dir_email/searchOptionsform_wf_fop_mail_host_box_dir_email_thread_create_email?value=' + encodeURIComponent(self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].value) + '&deps=' + <?php echo htmlentities(json_encode(urlencode(json_encode($deps)))); ?> + '&str=' + encodeURIComponent(value)).then(function (result) {
					self.setAttribute('data-lastsearch', value);
					// Options eintragen
					$(self.parentNode.firstElementChild).empty();
					if (self.list) {
						$(self.list).empty();
					} else {
						var list = document.createElement('datalist');
						self.parentNode.appendChild(list);
						list.id = 'datalist' + String(Math.random()).substr(2);
						self.setAttribute('list', list.id);
						self.list = list;
					}
					for (var i = 0; i < result.length; i++) {
						var option = document.createElement('option');
						option.value = result[i].ID;
						option.text = result[i].description;
						self.parentNode.firstElementChild.appendChild(option);
						if (option.textContent == value) {
							option.selected = i;
							$(self.parentElement).find('.fop-remove-after-change').remove();
						}

						var option = document.createElement('option');
						option.value = result[i].description;
						self.list.appendChild(option);
					}
					/* reset busy flag */
					$(self).removeClass('busy');
					if ($(self).hasClass('busy-dirty')) {
						$(self).removeClass('busy-dirty');
						updateSuggestions(); //
					}
				});
			};
			if ($(self).hasClass('busy')) {
				// busy: busy->dirty
				$(self).addClass('busy-dirty');
				$(self).removeClass('busy');
				// mark as busy-dirty; updateSuggestions will trigger itself again
			} else if ($(self).hasClass('busy-dirty')) {
				// already dirty - we can save one reload cycle
			} else {
				// no request pending yet
				updateSuggestions();
			}
		<?php } ?>
	" onclick="this.focus(); if (this.value == <?php echo (_('pSelect'));?>) this.select();">
	<?php
		if (count($items) == 0) {
			?><span class="mdl-textfield__error fop-form-error" style="visibility: visible;"><?php echo(_('no_dropdown_values')) ?></span><?php
		}
	?>
	<?php if (isset($isForbidden) && $isForbidden) {
			?><span class="mdl-textfield__error fop-form-error fop-remove-after-change" style="visibility: visible;"><?php echo(_('invalid')) ?></span><?php
	} ?>
	 <span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span>
</div>

<?php

    
  }

  public static function renderEditform_wf_fop_mail_host_box_dir_email_recipient_create_emailAction($value, $deps, $condition, $fop_field_name = null ) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Fop_mail_host_box_dir_email::getItems($deps, $value); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	?>
<div class="mdlext-selectfield mdlext-js-selectfield" style="max-width:  300px;">
	<select tabindex='-1' class="selectdropdown mdlext-selectfield__select" name="email" data-default="<?php echo htmlentities($value ?: 0); ?>" style="color: rgba(0,0,0,0);" onchange="
		var val = this.value;
		if (val == '_more') {
			$(this.parentNode.parentNode).find('.fop-ddt-search').click();
			return;
		}
		this.nextElementSibling.value = this.options[this.selectedIndex].text;
		this.nextElementSibling.focus();
		this.nextElementSibling.select();
		$(this.parentElement).find('.fop-remove-after-change').remove();
		this.value = val;

		var model = this.getAttribute('xng-model');
		if (model) {
			$(this).scope().$eval(model + '=' + JSON.stringify(this.value));
			$(this).scope().$apply();
		}
	">
		<?php $text = ''; ?><?php
			$isLong = count($items) && $items[count($items) - 1]['ID'] == '_more';
			foreach ($items AS $item) if (!$condition || $item[$condition]) {
				?><option value="<?php echo htmlentities($item['ID'])?>" <?php
					if ($item['ID'] == $value) {
						// Wert ist gewählt
						echo "selected";
						$text = $item['description'];
						if (isset($item['forbidden'])) {
							$isForbidden = true;
							echo ' class="fop-remove-after-change"';
						}
					}?>><?php echo htmlentities($item['description']); ?></option>
		<?php
			}
		?>
	</select>
	<input class="mdl-textfield__input" value="<?php echo htmlentities($text); ?>" style="position: absolute; top: 20px; left: 4px; width: calc(100% - 32px);" type="text" data-lastsearch="" onkeydown="
		if (event.keyCode == 13) {
			event.preventDefault();
			event.stopPropagation();
			// ENTER: erstbestes passendes Element zuweisen
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				if (this.parentNode.firstElementChild.options[x].text.includes(this.value)) { // Text (z.B. EAN) kommt darin vor:
					this.parentNode.firstElementChild.selectedIndex = x;
					this.value = this.parentNode.firstElementChild.options[x].text;
					var model = this.parentNode.firstElementChild.getAttribute('xng-model');
					if (model) {
						$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
						$(this).scope().$apply();
					}
					$(this.parentElement).find('.fop-remove-after-change').remove();
					tabNext(this);
					return false;
				}
			}
			return false;
		}
		if (!this.list) {
			var list = document.createElement('datalist');
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				var option = document.createElement('option');
				option.value = this.parentNode.firstElementChild.options[x].text;
				list.appendChild(option);
			}
			this.parentNode.appendChild(list);
			list.id = 'datalist' + String(Math.random()).substr(2);
			this.setAttribute('list', list.id);
			this.setAttribute('onkeydown', this.getAttribute('onchange'));
			this.list = list;
		}
	" oninput="
		for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
			if (this.value == this.parentNode.firstElementChild.options[x].text) {
				var model = this.parentNode.firstElementChild.getAttribute('xng-model');
				if (model) {
					$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
					$(this).scope().$apply();
				}
				this.parentNode.firstElementChild.selectedIndex = x;
				$(this.parentElement).find('.fop-remove-after-change').remove();
			}
		}
		<?php if ($isLong) { ?>
			// Ajax+SQL mit LIKE-Query LIMIT
			var self = this;
			function updateSuggestions() {
				var value = self.value; // save in variable to keep stable during ajax
				if (value == self.getAttribute('data-lastsearch') || value == self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].text) {
					$(self).removeClass('busy');
					$(self).removeClass('busy-dirty');
					return;
				}
				$(self).addClass('busy');
				$.get('Tables/Fop_mail_host_box_dir_email/searchOptionsform_wf_fop_mail_host_box_dir_email_recipient_create_email?value=' + encodeURIComponent(self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].value) + '&deps=' + <?php echo htmlentities(json_encode(urlencode(json_encode($deps)))); ?> + '&str=' + encodeURIComponent(value)).then(function (result) {
					self.setAttribute('data-lastsearch', value);
					// Options eintragen
					$(self.parentNode.firstElementChild).empty();
					if (self.list) {
						$(self.list).empty();
					} else {
						var list = document.createElement('datalist');
						self.parentNode.appendChild(list);
						list.id = 'datalist' + String(Math.random()).substr(2);
						self.setAttribute('list', list.id);
						self.list = list;
					}
					for (var i = 0; i < result.length; i++) {
						var option = document.createElement('option');
						option.value = result[i].ID;
						option.text = result[i].description;
						self.parentNode.firstElementChild.appendChild(option);
						if (option.textContent == value) {
							option.selected = i;
							$(self.parentElement).find('.fop-remove-after-change').remove();
						}

						var option = document.createElement('option');
						option.value = result[i].description;
						self.list.appendChild(option);
					}
					/* reset busy flag */
					$(self).removeClass('busy');
					if ($(self).hasClass('busy-dirty')) {
						$(self).removeClass('busy-dirty');
						updateSuggestions(); //
					}
				});
			};
			if ($(self).hasClass('busy')) {
				// busy: busy->dirty
				$(self).addClass('busy-dirty');
				$(self).removeClass('busy');
				// mark as busy-dirty; updateSuggestions will trigger itself again
			} else if ($(self).hasClass('busy-dirty')) {
				// already dirty - we can save one reload cycle
			} else {
				// no request pending yet
				updateSuggestions();
			}
		<?php } ?>
	" onclick="this.focus(); if (this.value == <?php echo (_('pSelect'));?>) this.select();">
	<?php
		if (count($items) == 0) {
			?><span class="mdl-textfield__error fop-form-error" style="visibility: visible;"><?php echo(_('no_dropdown_values')) ?></span><?php
		}
	?>
	<?php if (isset($isForbidden) && $isForbidden) {
			?><span class="mdl-textfield__error fop-form-error fop-remove-after-change" style="visibility: visible;"><?php echo(_('invalid')) ?></span><?php
	} ?>
	 <span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span>
</div>

<?php

    
  }

  public static function renderEditform_wf_fop_mail_host_box_dir_email_attachment_create_emailAction($value, $deps, $condition, $fop_field_name = null ) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Fop_mail_host_box_dir_email::getItems($deps, $value); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	?>
<div class="mdlext-selectfield mdlext-js-selectfield" style="max-width:  300px;">
	<select tabindex='-1' class="selectdropdown mdlext-selectfield__select" name="email" data-default="<?php echo htmlentities($value ?: 0); ?>" style="color: rgba(0,0,0,0);" onchange="
		var val = this.value;
		if (val == '_more') {
			$(this.parentNode.parentNode).find('.fop-ddt-search').click();
			return;
		}
		this.nextElementSibling.value = this.options[this.selectedIndex].text;
		this.nextElementSibling.focus();
		this.nextElementSibling.select();
		$(this.parentElement).find('.fop-remove-after-change').remove();
		this.value = val;

		var model = this.getAttribute('xng-model');
		if (model) {
			$(this).scope().$eval(model + '=' + JSON.stringify(this.value));
			$(this).scope().$apply();
		}
	">
		<?php $text = ''; ?><?php
			$isLong = count($items) && $items[count($items) - 1]['ID'] == '_more';
			foreach ($items AS $item) if (!$condition || $item[$condition]) {
				?><option value="<?php echo htmlentities($item['ID'])?>" <?php
					if ($item['ID'] == $value) {
						// Wert ist gewählt
						echo "selected";
						$text = $item['description'];
						if (isset($item['forbidden'])) {
							$isForbidden = true;
							echo ' class="fop-remove-after-change"';
						}
					}?>><?php echo htmlentities($item['description']); ?></option>
		<?php
			}
		?>
	</select>
	<input class="mdl-textfield__input" value="<?php echo htmlentities($text); ?>" style="position: absolute; top: 20px; left: 4px; width: calc(100% - 32px);" type="text" data-lastsearch="" onkeydown="
		if (event.keyCode == 13) {
			event.preventDefault();
			event.stopPropagation();
			// ENTER: erstbestes passendes Element zuweisen
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				if (this.parentNode.firstElementChild.options[x].text.includes(this.value)) { // Text (z.B. EAN) kommt darin vor:
					this.parentNode.firstElementChild.selectedIndex = x;
					this.value = this.parentNode.firstElementChild.options[x].text;
					var model = this.parentNode.firstElementChild.getAttribute('xng-model');
					if (model) {
						$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
						$(this).scope().$apply();
					}
					$(this.parentElement).find('.fop-remove-after-change').remove();
					tabNext(this);
					return false;
				}
			}
			return false;
		}
		if (!this.list) {
			var list = document.createElement('datalist');
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				var option = document.createElement('option');
				option.value = this.parentNode.firstElementChild.options[x].text;
				list.appendChild(option);
			}
			this.parentNode.appendChild(list);
			list.id = 'datalist' + String(Math.random()).substr(2);
			this.setAttribute('list', list.id);
			this.setAttribute('onkeydown', this.getAttribute('onchange'));
			this.list = list;
		}
	" oninput="
		for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
			if (this.value == this.parentNode.firstElementChild.options[x].text) {
				var model = this.parentNode.firstElementChild.getAttribute('xng-model');
				if (model) {
					$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
					$(this).scope().$apply();
				}
				this.parentNode.firstElementChild.selectedIndex = x;
				$(this.parentElement).find('.fop-remove-after-change').remove();
			}
		}
		<?php if ($isLong) { ?>
			// Ajax+SQL mit LIKE-Query LIMIT
			var self = this;
			function updateSuggestions() {
				var value = self.value; // save in variable to keep stable during ajax
				if (value == self.getAttribute('data-lastsearch') || value == self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].text) {
					$(self).removeClass('busy');
					$(self).removeClass('busy-dirty');
					return;
				}
				$(self).addClass('busy');
				$.get('Tables/Fop_mail_host_box_dir_email/searchOptionsform_wf_fop_mail_host_box_dir_email_attachment_create_email?value=' + encodeURIComponent(self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].value) + '&deps=' + <?php echo htmlentities(json_encode(urlencode(json_encode($deps)))); ?> + '&str=' + encodeURIComponent(value)).then(function (result) {
					self.setAttribute('data-lastsearch', value);
					// Options eintragen
					$(self.parentNode.firstElementChild).empty();
					if (self.list) {
						$(self.list).empty();
					} else {
						var list = document.createElement('datalist');
						self.parentNode.appendChild(list);
						list.id = 'datalist' + String(Math.random()).substr(2);
						self.setAttribute('list', list.id);
						self.list = list;
					}
					for (var i = 0; i < result.length; i++) {
						var option = document.createElement('option');
						option.value = result[i].ID;
						option.text = result[i].description;
						self.parentNode.firstElementChild.appendChild(option);
						if (option.textContent == value) {
							option.selected = i;
							$(self.parentElement).find('.fop-remove-after-change').remove();
						}

						var option = document.createElement('option');
						option.value = result[i].description;
						self.list.appendChild(option);
					}
					/* reset busy flag */
					$(self).removeClass('busy');
					if ($(self).hasClass('busy-dirty')) {
						$(self).removeClass('busy-dirty');
						updateSuggestions(); //
					}
				});
			};
			if ($(self).hasClass('busy')) {
				// busy: busy->dirty
				$(self).addClass('busy-dirty');
				$(self).removeClass('busy');
				// mark as busy-dirty; updateSuggestions will trigger itself again
			} else if ($(self).hasClass('busy-dirty')) {
				// already dirty - we can save one reload cycle
			} else {
				// no request pending yet
				updateSuggestions();
			}
		<?php } ?>
	" onclick="this.focus(); if (this.value == <?php echo (_('pSelect'));?>) this.select();">
	<?php
		if (count($items) == 0) {
			?><span class="mdl-textfield__error fop-form-error" style="visibility: visible;"><?php echo(_('no_dropdown_values')) ?></span><?php
		}
	?>
	<?php if (isset($isForbidden) && $isForbidden) {
			?><span class="mdl-textfield__error fop-form-error fop-remove-after-change" style="visibility: visible;"><?php echo(_('invalid')) ?></span><?php
	} ?>
	 <span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span>
</div>

<?php

    
  }

  public static function renderEditform_wf_fop_mail_host_box_dir_email_thread_edit_emailAction($value, $deps, $condition, $fop_field_name = null ) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Fop_mail_host_box_dir_email::getItems($deps, $value); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	?>
<div class="mdlext-selectfield mdlext-js-selectfield" style="max-width:  300px;">
	<select tabindex='-1' xng-model='form[&apos;email&apos;]' class="selectdropdown mdlext-selectfield__select" name="email" data-default="<?php echo htmlentities($value ?: 0); ?>" style="color: rgba(0,0,0,0);" onchange="
		var val = this.value;
		if (val == '_more') {
			$(this.parentNode.parentNode).find('.fop-ddt-search').click();
			return;
		}
		this.nextElementSibling.value = this.options[this.selectedIndex].text;
		this.nextElementSibling.focus();
		this.nextElementSibling.select();
		$(this.parentElement).find('.fop-remove-after-change').remove();
		this.value = val;

		var model = this.getAttribute('xng-model');
		if (model) {
			$(this).scope().$eval(model + '=' + JSON.stringify(this.value));
			$(this).scope().$apply();
		}
	">
		<?php $text = ''; ?><?php
			$isLong = count($items) && $items[count($items) - 1]['ID'] == '_more';
			foreach ($items AS $item) if (!$condition || $item[$condition]) {
				?><option value="<?php echo htmlentities($item['ID'])?>" <?php
					if ($item['ID'] == $value) {
						// Wert ist gewählt
						echo "selected";
						$text = $item['description'];
						if (isset($item['forbidden'])) {
							$isForbidden = true;
							echo ' class="fop-remove-after-change"';
						}
					}?>><?php echo htmlentities($item['description']); ?></option>
		<?php
			}
		?>
	</select>
	<input ng-trigger-change='form[&apos;email&apos;]' fop-type='Fop_mail_host_box_dir_email' class="mdl-textfield__input" value="<?php echo htmlentities($text); ?>" style="position: absolute; top: 20px; left: 4px; width: calc(100% - 32px);" type="text" data-lastsearch="" onkeydown="
		if (event.keyCode == 13) {
			event.preventDefault();
			event.stopPropagation();
			// ENTER: erstbestes passendes Element zuweisen
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				if (this.parentNode.firstElementChild.options[x].text.includes(this.value)) { // Text (z.B. EAN) kommt darin vor:
					this.parentNode.firstElementChild.selectedIndex = x;
					this.value = this.parentNode.firstElementChild.options[x].text;
					var model = this.parentNode.firstElementChild.getAttribute('xng-model');
					if (model) {
						$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
						$(this).scope().$apply();
					}
					$(this.parentElement).find('.fop-remove-after-change').remove();
					tabNext(this);
					return false;
				}
			}
			return false;
		}
		if (!this.list) {
			var list = document.createElement('datalist');
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				var option = document.createElement('option');
				option.value = this.parentNode.firstElementChild.options[x].text;
				list.appendChild(option);
			}
			this.parentNode.appendChild(list);
			list.id = 'datalist' + String(Math.random()).substr(2);
			this.setAttribute('list', list.id);
			this.setAttribute('onkeydown', this.getAttribute('onchange'));
			this.list = list;
		}
	" oninput="
		for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
			if (this.value == this.parentNode.firstElementChild.options[x].text) {
				var model = this.parentNode.firstElementChild.getAttribute('xng-model');
				if (model) {
					$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
					$(this).scope().$apply();
				}
				this.parentNode.firstElementChild.selectedIndex = x;
				$(this.parentElement).find('.fop-remove-after-change').remove();
			}
		}
		<?php if ($isLong) { ?>
			// Ajax+SQL mit LIKE-Query LIMIT
			var self = this;
			function updateSuggestions() {
				var value = self.value; // save in variable to keep stable during ajax
				if (value == self.getAttribute('data-lastsearch') || value == self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].text) {
					$(self).removeClass('busy');
					$(self).removeClass('busy-dirty');
					return;
				}
				$(self).addClass('busy');
				$.get('Tables/Fop_mail_host_box_dir_email/searchOptionsform_wf_fop_mail_host_box_dir_email_thread_edit_email?value=' + encodeURIComponent(self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].value) + '&deps=' + <?php echo htmlentities(json_encode(urlencode(json_encode($deps)))); ?> + '&str=' + encodeURIComponent(value)).then(function (result) {
					self.setAttribute('data-lastsearch', value);
					// Options eintragen
					$(self.parentNode.firstElementChild).empty();
					if (self.list) {
						$(self.list).empty();
					} else {
						var list = document.createElement('datalist');
						self.parentNode.appendChild(list);
						list.id = 'datalist' + String(Math.random()).substr(2);
						self.setAttribute('list', list.id);
						self.list = list;
					}
					for (var i = 0; i < result.length; i++) {
						var option = document.createElement('option');
						option.value = result[i].ID;
						option.text = result[i].description;
						self.parentNode.firstElementChild.appendChild(option);
						if (option.textContent == value) {
							option.selected = i;
							$(self.parentElement).find('.fop-remove-after-change').remove();
						}

						var option = document.createElement('option');
						option.value = result[i].description;
						self.list.appendChild(option);
					}
					/* reset busy flag */
					$(self).removeClass('busy');
					if ($(self).hasClass('busy-dirty')) {
						$(self).removeClass('busy-dirty');
						updateSuggestions(); //
					}
				});
			};
			if ($(self).hasClass('busy')) {
				// busy: busy->dirty
				$(self).addClass('busy-dirty');
				$(self).removeClass('busy');
				// mark as busy-dirty; updateSuggestions will trigger itself again
			} else if ($(self).hasClass('busy-dirty')) {
				// already dirty - we can save one reload cycle
			} else {
				// no request pending yet
				updateSuggestions();
			}
		<?php } ?>
	" onclick="this.focus(); if (this.value == <?php echo (_('pSelect'));?>) this.select();">
	<?php
		if (count($items) == 0) {
			?><span class="mdl-textfield__error fop-form-error" style="visibility: visible;"><?php echo(_('no_dropdown_values')) ?></span><?php
		}
	?>
	<?php if (isset($isForbidden) && $isForbidden) {
			?><span class="mdl-textfield__error fop-form-error fop-remove-after-change" style="visibility: visible;"><?php echo(_('invalid')) ?></span><?php
	} ?>
	 <span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span>
</div>

<?php

    
  }

  public static function renderEditform_wf_fop_mail_host_box_dir_email_recipient_edit_emailAction($value, $deps, $condition, $fop_field_name = null ) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Fop_mail_host_box_dir_email::getItems($deps, $value); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	?>
<div class="mdlext-selectfield mdlext-js-selectfield" style="max-width:  300px;">
	<select tabindex='-1' class="selectdropdown mdlext-selectfield__select" name="email" data-default="<?php echo htmlentities($value ?: 0); ?>" style="color: rgba(0,0,0,0);" onchange="
		var val = this.value;
		if (val == '_more') {
			$(this.parentNode.parentNode).find('.fop-ddt-search').click();
			return;
		}
		this.nextElementSibling.value = this.options[this.selectedIndex].text;
		this.nextElementSibling.focus();
		this.nextElementSibling.select();
		$(this.parentElement).find('.fop-remove-after-change').remove();
		this.value = val;

		var model = this.getAttribute('xng-model');
		if (model) {
			$(this).scope().$eval(model + '=' + JSON.stringify(this.value));
			$(this).scope().$apply();
		}
	">
		<?php $text = ''; ?><?php
			$isLong = count($items) && $items[count($items) - 1]['ID'] == '_more';
			foreach ($items AS $item) if (!$condition || $item[$condition]) {
				?><option value="<?php echo htmlentities($item['ID'])?>" <?php
					if ($item['ID'] == $value) {
						// Wert ist gewählt
						echo "selected";
						$text = $item['description'];
						if (isset($item['forbidden'])) {
							$isForbidden = true;
							echo ' class="fop-remove-after-change"';
						}
					}?>><?php echo htmlentities($item['description']); ?></option>
		<?php
			}
		?>
	</select>
	<input class="mdl-textfield__input" value="<?php echo htmlentities($text); ?>" style="position: absolute; top: 20px; left: 4px; width: calc(100% - 32px);" type="text" data-lastsearch="" onkeydown="
		if (event.keyCode == 13) {
			event.preventDefault();
			event.stopPropagation();
			// ENTER: erstbestes passendes Element zuweisen
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				if (this.parentNode.firstElementChild.options[x].text.includes(this.value)) { // Text (z.B. EAN) kommt darin vor:
					this.parentNode.firstElementChild.selectedIndex = x;
					this.value = this.parentNode.firstElementChild.options[x].text;
					var model = this.parentNode.firstElementChild.getAttribute('xng-model');
					if (model) {
						$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
						$(this).scope().$apply();
					}
					$(this.parentElement).find('.fop-remove-after-change').remove();
					tabNext(this);
					return false;
				}
			}
			return false;
		}
		if (!this.list) {
			var list = document.createElement('datalist');
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				var option = document.createElement('option');
				option.value = this.parentNode.firstElementChild.options[x].text;
				list.appendChild(option);
			}
			this.parentNode.appendChild(list);
			list.id = 'datalist' + String(Math.random()).substr(2);
			this.setAttribute('list', list.id);
			this.setAttribute('onkeydown', this.getAttribute('onchange'));
			this.list = list;
		}
	" oninput="
		for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
			if (this.value == this.parentNode.firstElementChild.options[x].text) {
				var model = this.parentNode.firstElementChild.getAttribute('xng-model');
				if (model) {
					$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
					$(this).scope().$apply();
				}
				this.parentNode.firstElementChild.selectedIndex = x;
				$(this.parentElement).find('.fop-remove-after-change').remove();
			}
		}
		<?php if ($isLong) { ?>
			// Ajax+SQL mit LIKE-Query LIMIT
			var self = this;
			function updateSuggestions() {
				var value = self.value; // save in variable to keep stable during ajax
				if (value == self.getAttribute('data-lastsearch') || value == self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].text) {
					$(self).removeClass('busy');
					$(self).removeClass('busy-dirty');
					return;
				}
				$(self).addClass('busy');
				$.get('Tables/Fop_mail_host_box_dir_email/searchOptionsform_wf_fop_mail_host_box_dir_email_recipient_edit_email?value=' + encodeURIComponent(self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].value) + '&deps=' + <?php echo htmlentities(json_encode(urlencode(json_encode($deps)))); ?> + '&str=' + encodeURIComponent(value)).then(function (result) {
					self.setAttribute('data-lastsearch', value);
					// Options eintragen
					$(self.parentNode.firstElementChild).empty();
					if (self.list) {
						$(self.list).empty();
					} else {
						var list = document.createElement('datalist');
						self.parentNode.appendChild(list);
						list.id = 'datalist' + String(Math.random()).substr(2);
						self.setAttribute('list', list.id);
						self.list = list;
					}
					for (var i = 0; i < result.length; i++) {
						var option = document.createElement('option');
						option.value = result[i].ID;
						option.text = result[i].description;
						self.parentNode.firstElementChild.appendChild(option);
						if (option.textContent == value) {
							option.selected = i;
							$(self.parentElement).find('.fop-remove-after-change').remove();
						}

						var option = document.createElement('option');
						option.value = result[i].description;
						self.list.appendChild(option);
					}
					/* reset busy flag */
					$(self).removeClass('busy');
					if ($(self).hasClass('busy-dirty')) {
						$(self).removeClass('busy-dirty');
						updateSuggestions(); //
					}
				});
			};
			if ($(self).hasClass('busy')) {
				// busy: busy->dirty
				$(self).addClass('busy-dirty');
				$(self).removeClass('busy');
				// mark as busy-dirty; updateSuggestions will trigger itself again
			} else if ($(self).hasClass('busy-dirty')) {
				// already dirty - we can save one reload cycle
			} else {
				// no request pending yet
				updateSuggestions();
			}
		<?php } ?>
	" onclick="this.focus(); if (this.value == <?php echo (_('pSelect'));?>) this.select();">
	<?php
		if (count($items) == 0) {
			?><span class="mdl-textfield__error fop-form-error" style="visibility: visible;"><?php echo(_('no_dropdown_values')) ?></span><?php
		}
	?>
	<?php if (isset($isForbidden) && $isForbidden) {
			?><span class="mdl-textfield__error fop-form-error fop-remove-after-change" style="visibility: visible;"><?php echo(_('invalid')) ?></span><?php
	} ?>
	 <span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span>
</div>

<?php

    
  }

  public static function renderEditform_wf_fop_mail_host_box_dir_email_attachment_edit_emailAction($value, $deps, $condition, $fop_field_name = null ) { 
    
    
    // --- BLOCK: access ---
    
    // --- BLOCK: main ---
    
	if (is_string($deps)) $deps = json_decode($deps, true);
	$items = \Types\Fop_mail_host_box_dir_email::getItems($deps, $value); // Annahme: getItems prüft je Item die Zugriffsregeln und gibt notfalls [] zurück
	?>
<div class="mdlext-selectfield mdlext-js-selectfield" style="max-width:  300px;">
	<select tabindex='-1' class="selectdropdown mdlext-selectfield__select" name="email" data-default="<?php echo htmlentities($value ?: 0); ?>" style="color: rgba(0,0,0,0);" onchange="
		var val = this.value;
		if (val == '_more') {
			$(this.parentNode.parentNode).find('.fop-ddt-search').click();
			return;
		}
		this.nextElementSibling.value = this.options[this.selectedIndex].text;
		this.nextElementSibling.focus();
		this.nextElementSibling.select();
		$(this.parentElement).find('.fop-remove-after-change').remove();
		this.value = val;

		var model = this.getAttribute('xng-model');
		if (model) {
			$(this).scope().$eval(model + '=' + JSON.stringify(this.value));
			$(this).scope().$apply();
		}
	">
		<?php $text = ''; ?><?php
			$isLong = count($items) && $items[count($items) - 1]['ID'] == '_more';
			foreach ($items AS $item) if (!$condition || $item[$condition]) {
				?><option value="<?php echo htmlentities($item['ID'])?>" <?php
					if ($item['ID'] == $value) {
						// Wert ist gewählt
						echo "selected";
						$text = $item['description'];
						if (isset($item['forbidden'])) {
							$isForbidden = true;
							echo ' class="fop-remove-after-change"';
						}
					}?>><?php echo htmlentities($item['description']); ?></option>
		<?php
			}
		?>
	</select>
	<input class="mdl-textfield__input" value="<?php echo htmlentities($text); ?>" style="position: absolute; top: 20px; left: 4px; width: calc(100% - 32px);" type="text" data-lastsearch="" onkeydown="
		if (event.keyCode == 13) {
			event.preventDefault();
			event.stopPropagation();
			// ENTER: erstbestes passendes Element zuweisen
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				if (this.parentNode.firstElementChild.options[x].text.includes(this.value)) { // Text (z.B. EAN) kommt darin vor:
					this.parentNode.firstElementChild.selectedIndex = x;
					this.value = this.parentNode.firstElementChild.options[x].text;
					var model = this.parentNode.firstElementChild.getAttribute('xng-model');
					if (model) {
						$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
						$(this).scope().$apply();
					}
					$(this.parentElement).find('.fop-remove-after-change').remove();
					tabNext(this);
					return false;
				}
			}
			return false;
		}
		if (!this.list) {
			var list = document.createElement('datalist');
			for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
				var option = document.createElement('option');
				option.value = this.parentNode.firstElementChild.options[x].text;
				list.appendChild(option);
			}
			this.parentNode.appendChild(list);
			list.id = 'datalist' + String(Math.random()).substr(2);
			this.setAttribute('list', list.id);
			this.setAttribute('onkeydown', this.getAttribute('onchange'));
			this.list = list;
		}
	" oninput="
		for (var x = 0; x < this.parentNode.firstElementChild.options.length; x++) {
			if (this.value == this.parentNode.firstElementChild.options[x].text) {
				var model = this.parentNode.firstElementChild.getAttribute('xng-model');
				if (model) {
					$(this).scope().$eval(model + '=' + JSON.stringify(this.parentNode.firstElementChild.options[x].value));
					$(this).scope().$apply();
				}
				this.parentNode.firstElementChild.selectedIndex = x;
				$(this.parentElement).find('.fop-remove-after-change').remove();
			}
		}
		<?php if ($isLong) { ?>
			// Ajax+SQL mit LIKE-Query LIMIT
			var self = this;
			function updateSuggestions() {
				var value = self.value; // save in variable to keep stable during ajax
				if (value == self.getAttribute('data-lastsearch') || value == self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].text) {
					$(self).removeClass('busy');
					$(self).removeClass('busy-dirty');
					return;
				}
				$(self).addClass('busy');
				$.get('Tables/Fop_mail_host_box_dir_email/searchOptionsform_wf_fop_mail_host_box_dir_email_attachment_edit_email?value=' + encodeURIComponent(self.parentNode.firstElementChild.options[self.parentNode.firstElementChild.selectedIndex].value) + '&deps=' + <?php echo htmlentities(json_encode(urlencode(json_encode($deps)))); ?> + '&str=' + encodeURIComponent(value)).then(function (result) {
					self.setAttribute('data-lastsearch', value);
					// Options eintragen
					$(self.parentNode.firstElementChild).empty();
					if (self.list) {
						$(self.list).empty();
					} else {
						var list = document.createElement('datalist');
						self.parentNode.appendChild(list);
						list.id = 'datalist' + String(Math.random()).substr(2);
						self.setAttribute('list', list.id);
						self.list = list;
					}
					for (var i = 0; i < result.length; i++) {
						var option = document.createElement('option');
						option.value = result[i].ID;
						option.text = result[i].description;
						self.parentNode.firstElementChild.appendChild(option);
						if (option.textContent == value) {
							option.selected = i;
							$(self.parentElement).find('.fop-remove-after-change').remove();
						}

						var option = document.createElement('option');
						option.value = result[i].description;
						self.list.appendChild(option);
					}
					/* reset busy flag */
					$(self).removeClass('busy');
					if ($(self).hasClass('busy-dirty')) {
						$(self).removeClass('busy-dirty');
						updateSuggestions(); //
					}
				});
			};
			if ($(self).hasClass('busy')) {
				// busy: busy->dirty
				$(self).addClass('busy-dirty');
				$(self).removeClass('busy');
				// mark as busy-dirty; updateSuggestions will trigger itself again
			} else if ($(self).hasClass('busy-dirty')) {
				// already dirty - we can save one reload cycle
			} else {
				// no request pending yet
				updateSuggestions();
			}
		<?php } ?>
	" onclick="this.focus(); if (this.value == <?php echo (_('pSelect'));?>) this.select();">
	<?php
		if (count($items) == 0) {
			?><span class="mdl-textfield__error fop-form-error" style="visibility: visible;"><?php echo(_('no_dropdown_values')) ?></span><?php
		}
	?>
	<?php if (isset($isForbidden) && $isForbidden) {
			?><span class="mdl-textfield__error fop-form-error fop-remove-after-change" style="visibility: visible;"><?php echo(_('invalid')) ?></span><?php
	} ?>
	 <span class="mdl-textfield__error"><div><?php echo(_('invalidinput')) ?></div></span>
</div>

<?php

    
  }

  public static function imap_move($boxid, $uid, $from, $to, $id) { 
    
    
    // --- BLOCK: main ---
    		
		$res = \FOP\Database::query('SELECT hoststr FROM fop_mail_host_box WHERE '.qi('ID').'  = ' .\FOP\Database::quote($boxid). ' LIMIT 1')->fetch(\PDO::FETCH_ASSOC);
		$mbox = \Tables\Fop_mail_host_box_dir::imap_open($boxid, $from, '');
		$msgno = imap_msgno($mbox, $uid);	
		$hoststr = $res['hoststr'];
		$list = imap_list($mbox, $hoststr, '*');
		if (is_array($list)) {
    			foreach ($list as $val) {
				//testtest
        			if($hoststr . $to == $val){
					imap_mail_move($mbox, $msgno, $to);
					\FOP\Database::query('DELETE FROM fop_mail_host_box_dir_email WHERE '.qi('ID').' = ' . \FOP\Database::quote($id));
					$latestuid = \FOP\Database::query('SELECT latestuid FROM fop_imaplistener WHERE mailboxid = ' . \FOP\Database::quote($boxid) . ' AND directorystr = ' . \FOP\Database::quote($from))->fetchColumn();
					if($uid == $latestuid){
						\FOP\Database::query('UPDATE fop_imaplistener SET latestuid = ' . \FOP\Database::quote($uid). ' WHERE mailboxid = ' . \FOP\Database::quote($boxid) . ' AND directorystr = ' . \FOP\Database::quote($from));
					}
					return $mbox;
				}
    			}
			imap_gc($mbox, IMAP_GC_ELT | IMAP_GC_ENV | IMAP_GC_TEXTS);
			imap_close($mbox);
			return false;	
		} else {
			imap_gc($mbox, IMAP_GC_ELT | IMAP_GC_ENV | IMAP_GC_TEXTS);
			imap_close($mbox);
    		return false;
		}
	
    
  }

  public static function deleteAction($id) { 
    
    // Methodenimplementierung überschrieben.
    throw new \FOP\AccessDeniedException();return false;
  }

  public static function indexAction() { 
    
    
    // --- BLOCK: access ---
    if(!(((\FOP\User::getIsLoggedIn())) && (!\FOP\User::getIsGuest()))) throw new \FOP\AccessDeniedException();
    // --- BLOCK: main ---
    ?><?php
			header('Content-Type: text/html; charset=UTF-8');
			header('X-XSS-Protection: 1; mode=block');
			header('Strict-Transport-Security: max-age=63072000');
			header('X-Content-Type-Options: nosniff');
			header("Content-Security-Policy: default-src *  data: blob: 'unsafe-inline' 'unsafe-eval'; script-src * 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src *; style-src * data: blob: 'unsafe-inline'; font-src * data: blob: 'unsafe-inline';");


		?><!DOCTYPE html><html><head><title><?php echo(_('Emails')); ?></title><base href='<?php echo \FOP\Util::getCurrentBaseurl(); ?>'><meta name="google" content="notranslate"><meta http-equiv="Content-Language" content="<?php echo htmlentities(\FOP\I18n::getLocale()); ?>"><meta charset="utf-8"><link rel="stylesheet" type="text/css" href="style_dependencies.css?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"><link rel="stylesheet" type="text/css" href="style.css?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"><script type="text/javascript" src="js/script_dependencies.js?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"></script><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="mobile-web-app-capable" content="yes"><link rel="manifest" href="manifest.webmanifest"><script type="text/javascript">moment.locale('<?php echo(\FOP\I18n::getShortLocale()); ?>');</script><script type="text/javascript" src="js/form.js"></script><script type="text/javascript">window.globals = <?php
	echo json_encode(['user:superadmin' => /* TODO: resanitizer später mal */(integer) \FOP\User::getSuperadmin(), 'user:mitglied' => /* TODO: resanitizer später mal */(integer) \FOP\User::getMitglied(), 'user:gruppe' => /* TODO: resanitizer später mal */(integer) \FOP\User::getGruppe(), 'user:campaign' => /* TODO: resanitizer später mal */(integer) \FOP\User::getCampaign(), 'user:sammlung' => /* TODO: resanitizer später mal */(integer) \FOP\User::getSammlung(), 'user:protokoll' => /* TODO: resanitizer später mal */(integer) \FOP\User::getProtokoll(), 'user:ID' => /* TODO: resanitizer später mal */(integer) \FOP\User::getID(), 'user:buchhaltung' => /* TODO: resanitizer später mal */(integer) \FOP\User::getBuchhaltung()]);
?>;</script><script type="text/javascript" src="angular/<?php echo(\FOP\I18n::getShortLocale()); ?>/js/alltypes.js?v=<?php echo(\FOP\Util::getVersionAppendix()); ?>"></script><script type="text/javascript" src="angular/angular-i18n/angular-locale_<?php echo \FOP\I18n::getAngularLocale(); ?>.js"></script><script type="text/javascript" src="js/date-filter.js"></script><script type="text/javascript" src="js/dropdown.js"></script><script type="text/javascript" src="js/numeric.js"></script><script type="text/javascript" src="js/getparam.js"></script><script type="text/javascript" src="js/tables.js"></script>
		<script type="text/javascript" src="js/parsehash.js"></script><script type="text/javascript">
		window.query = <?php echo json_encode($_GET, JSON_FORCE_OBJECT); ?>;
		window.baseurl = <?php echo json_encode(\FOP\Util::getCurrentBaseurl()); ?>;

		window.i18n_weiter = <?php echo json_encode(_('Weiter'));?>;
		//Filter I18n:
		window.i18n_quartal = <?php echo json_encode(_('Quarter'));?>;
		window.i18n_alle = <?php echo json_encode(_('All'));?>;
		window.i18n_leere = <?php echo json_encode(_('Empty'));?>;
		window.i18n_tag = <?php echo json_encode(_('Tag'));?>;
		window.i18n_woche = <?php echo json_encode(_('Woche'));?>;
		window.i18n_zeitraum = <?php echo json_encode(_('Period'));?>;
		window.i18n_monat = <?php echo json_encode(_('Monat'));?>;
		window.i18n_jahr = <?php echo json_encode(_('Jahr'));?>;
		window.i18n_von = <?php echo json_encode(_('filters_from'));?>;
		window.i18n_bis = <?php echo json_encode(_('filters_to'));?>;
		window.i18n_tabButton = <?php echo json_encode(_('open_in_new_tab'));?>;
		window.i18n_closeButton = <?php echo json_encode(_('close'));?>;
		</script></head><script type="text/javascript">const fopPushPublicKey = '<?php echo(addslashes(\FOP\Configuration::getFOPPushPublicKey())); ?>';
        const fopUserID = <?php echo(intval(\FOP\User::getID())); ?>;
        var fopPushDisabled = false;
    </script><script type="text/javascript" src="js/serviceworkersetup.js"></script><body ng-app='app'>
		<div class='mdl-js-snackbar mdl-snackbar' id='snackbar'>
			<div class='mdl-snackbar__text'></div>
			<button class='mdl-snackbar__action' type='button'></button>
		</div>
		<script>
			var snackbar = document.querySelector('#snackbar');
			componentHandler.upgradeElement(snackbar, 'MaterialSnackbar');
			$(function () {
				setTimeout(function () {
					$('.fop-layout').scrollTop(0);
				}, 0);
			});
		</script>

		<?php if (isset($_GET['popup'])) { ?>
		<header class="fop-header mdl-layout__header mdl-layout__header mdl-layout__header--scroll">
				<div class="mdl-layout__header-row">
					<span class="mdl-layout-title"><?php echo(_('Emails')); ?></span><div class="mdl-layout-spacer"></div><span class="noprint mdl-layout-title mdl-layout--large-screen-only"><div class="mdl-textfield mdl-js-textfield"><input id="supersearch" accesskey="f" class="mdl-textfield__input" type="text" onkeydown="if (event.keyCode == 13 && this.value) window.location.href = 'FOP/Index/searchURL?q=' + encodeURIComponent(this.value) + '&from=<?php echo htmlentities(urlencode(\FOP\Util::getBackUrl())); ?>';" value="<?php echo htmlentities($_GET['q'] ?? ''); ?>" style="border-bottom: 1px solid white;"/><label class="mdl-textfield__label" style="color: inherit"><?php echo(_('search')); ?> - <?php
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
			// MAC: Control+ davor
			echo 'Control + ';
		}
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {
			// Firefox
			if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
				// MAC: Control + Alt + key
				echo 'Alt + F';
			} else {
				echo 'Alt + Shift + F';
			}
		} else {
			// Internet Explorer, Chrome, Safari, Opera
			echo 'Alt + F';
		}
	?></label></div></span><i onclick='addFav(null)' class='material-icons fop-favorites' id='favorites_button'>star_border</i>
				</div>
      	</header>
			<style>
				.content {
					margin-top: 0px !important;
				}
			</style>
			<div id='content' class='popup' >
		<?php } else { ?>
			<div class="fop-layout mdl-layout mdl-js-layout mdl-layout--fixed-drawer mdl-layout--fixed-header">
			<header class="fop-header mdl-layout__header mdl-layout__header mdl-layout__header--scroll">
				<div class="mdl-layout__header-row">
					<span class="mdl-layout-title"><?php echo(_('Emails')); ?></span><div class="mdl-layout-spacer"></div><span class="noprint mdl-layout-title mdl-layout--large-screen-only"><div class="mdl-textfield mdl-js-textfield"><input id="supersearch" accesskey="f" class="mdl-textfield__input" type="text" onkeydown="if (event.keyCode == 13 && this.value) window.location.href = 'FOP/Index/searchURL?q=' + encodeURIComponent(this.value) + '&from=<?php echo htmlentities(urlencode(\FOP\Util::getBackUrl())); ?>';" value="<?php echo htmlentities($_GET['q'] ?? ''); ?>" style="border-bottom: 1px solid white;"/><label class="mdl-textfield__label" style="color: inherit"><?php echo(_('search')); ?> - <?php
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
			// MAC: Control+ davor
			echo 'Control + ';
		}
		if (strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') !== false) {
			// Firefox
			if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mac') !== false) {
				// MAC: Control + Alt + key
				echo 'Alt + F';
			} else {
				echo 'Alt + Shift + F';
			}
		} else {
			// Internet Explorer, Chrome, Safari, Opera
			echo 'Alt + F';
		}
	?></label></div></span><i onclick='addFav(null)' class='material-icons fop-favorites' id='favorites_button'>star_border</i>
				</div>
      		</header>


				<?php  \EasyEditor\Navigation::render(); ?>
      
				<main class="mdl-layout__content" id="content">
					<div class="fop-content">
						<?php } ?>
						
							<div class="content" id="1">
								

								<div
								 
								id="cardform-fop_mail_host_box_dir_email"
								style="width: 100%; height: 100%;"
								class='mdl-grid'
									ng-controller="FormFop_mail_host_box_dir_email" ng-init="form = <?php echo htmlentities(json_encode([]));
									?>;"
								>
								<?php
								 ?>
								<div id='fop-upbar'></div>
								<?php \DataView\Fop_mail_host_box_dir_email::renderScript(); ?>
									<?php
									$features = [];
									if (true && (true)) {
									$feature = [
										'id' => 'main_table',
										'title' => _('table'),
										'order' => '500-100', // 500-100 (50)
										'mode' => 'area', // area (51) / tab (50)
										'position' => 'full', // 
										'collapsed' => 0, // 0 (51) / 1 (50)
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => null
									];
									$features[$feature['id']] = $feature;
									}
									
									if (true && (false)) {
									$feature = [
										'id' => 'Nachricht',
										'title' => _('Nachricht'),
										'order' => '200-Nachricht', // 200-Nachricht (10-50)
										'mode' => 'region', // region (50)
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => '0'
									];
									$features[$feature['id']] = $feature;
									}
									
									if (true && (false || false)) {
									$feature = [
										'id' => 'main',
										'title' => _('Daten'),
										'order' => '500', // 500 (50) / 100 (20)
										'mode' => 'area', // 
										'position' => 'full', // 
										'collapsed' => 0, // 
										'canEdit' => !\FOP\User::getIsGuest(),
										'visibility' => '0' .'||'. '0'
									];
									$features[$feature['id']] = $feature;
									}
									

									
									/* load order from database
										schema: fop_form_feature(user, form, subid, key, value)
										key = (order, mode, position, collapsed)
									*/
									$upbar_collapsed = false;
									// default values
									foreach (\FOP\Database::query('SELECT subid, '.qi('key').', (SELECT '.qi('value').' FROM fop_form_feature b WHERE a.subid = b.subid AND a.'.qi('key').' = b.'.qi('key').' AND '.qi('user').' = '.intval(\FOP\User::getID()).' GROUP BY '.qi('value').' ORDER BY COUNT(*) DESC LIMIT 1) AS '.qi('value').' FROM fop_form_feature a WHERE '.qi('user').' = '.intval(\FOP\User::getID()).' GROUP BY subid, '.qi('key'))->fetchAll(\PDO::FETCH_ASSOC) AS $setting) {
										if (isset($features[$setting['subid']])) {
											$features[$setting['subid']][$setting['key']] = $setting['value'];
										}
									}
									// form specific special values
									foreach (\FOP\Database::query('SELECT subid, '.qi('key').', '.qi('value').' FROM fop_form_feature a WHERE form = \'fop_mail_host_box_dir_email\' AND '.qi('user').' = '.intval(\FOP\User::getID()).'')->fetchAll(\PDO::FETCH_ASSOC) AS $setting) {
										if (isset($features[$setting['subid']])) {
											$features[$setting['subid']][$setting['key']] = $setting['value'];
										} else if ($setting['subid'] == 'upbar' && $setting['key'] == 'collapsed') {
											$upbar_collapsed = (bool) $setting['value'];
										}
									}

									/* fill in the content of the features */
									if (true && (true)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['main_table']);
										?>
	<?php if (((\FOP\User::getIsLoggedIn())) && (!\FOP\User::getIsGuest())) { ?>
	<div id="fop_mail_host_box_dir_email-table" class="fop-dv"><?php
		if (\EasyEditor\FormFeature::isCollapsed()) {
			// #3198 lazy rendering:
			echo '<div class="fop-lazy-reload" onclick="reloadfop_mail_host_box_dir_email()"></div>'; // CSS class .fop-lazy-reload will be clicked after being showed
		} else {
			\DataView\Fop_mail_host_box_dir_email::renderTabTableAction();
		}
	?></div>
	<?php } ?>
	<?php
										\EasyEditor\FormFeature::pop();
										$features['main_table']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if (true && (false)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['Nachricht']);
										?><?php
										\EasyEditor\FormFeature::pop();
										$features['Nachricht']['html'] = ob_get_contents();
										ob_end_clean();
									}
									
									if (true && (false || false)) {
										ob_start();
										\EasyEditor\FormFeature::push($features['main']);
										?><?php
										\EasyEditor\FormFeature::pop();
										$features['main']['html'] = ob_get_contents();
										ob_end_clean();
									}
									

									uasort($features, function ($a, $b) {
										return strnatcmp($a['order'], $b['order']);
									});
									foreach ($features AS $feature) {
										\EasyEditor\FormFeature::render($feature);
									}
									?><script type='text/javascript'>
										$(function(){
											// bei Änderungen: prüfen, ob Form geändert wurde
											var formData = $('#cardform-fop_mail_host_box_dir_email').serialize();
											document.body.onbeforeunload = function () {
												if (formData != $('#cardform-fop_mail_host_box_dir_email').serialize()) {
													return 'Form data has changed - are you sure??';
												}
											};
											$('#cardform-fop_mail_host_box_dir_email').on('submit', function () {
												document.body.onbeforeunload = undefined;
											});
											<?php if ($upbar_collapsed) {
												?>$('#fop-bar-mainbutton').click();<?php
											} ?>
											$('#fop-bar-mainbutton').click(function () {
												setTimeout(function () {
													setCFF('upbar', 'collapsed', $('#fop-bar-container').is(':visible') ? 0 : 1);
												}, 440); /* perfect timing for fadeOut */
											});
										});
										
										function setCFF(id, key, value) {
											<?php if(!\FOP\User::getIsGuest()) { ?>
											$.get('FOP/Index/setCFF?form=fop_mail_host_box_dir_email&subid=' + encodeURIComponent(id) + '&key=' + encodeURIComponent(key) + '&value=' + encodeURIComponent(value)).then(function () {
												if (key == 'reset') {
													location.reload();
												}
											});
											<?php } /* EditAccess */ ?>
										}
										function setCFFOrder(fids) {
											<?php if(!\FOP\User::getIsGuest()) { ?>
											$.get('FOP/Index/setCFFOrder?form=fop_mail_host_box_dir_email&fids=' + encodeURIComponent(JSON.stringify(fids)));
											<?php } /* EditAccess */ ?>
										}
										$(function () {
											refreshTabHeaders($('#cardform-fop_mail_host_box_dir_email')); /* provided in js/form.js */
											// preselection
											if (location.hash.startsWith('#select:')) {
												$('[name="' + window.location.hash.slice(8) + '"]').focus().select();
											} else {
												$('#cardform-fop_mail_host_box_dir_email input[type!="hidden"],textarea,select[tabindex!="-1"]').not('.fop-disabled *').filter(':visible:first').focus().select();
											}
										});

										$(window).keydown(function(event) {
											 if (event.ctrlKey && String.fromCharCode(event.which).toLowerCase() == 's') {
												 event.preventDefault();
												 $('button[type=submit]').click();
												 return false;
											 }
										});

										
										$(document).on('keyup',function(evt) {
										   if (evt.keyCode == 27) {
												if (window.parent) {
													window.close(); // iframe:close
												} else {
													window.history.back();
												}
											}
												});
										
									</script>

							</div>
							

							</div>
							<div class="content" id="focus-supersearch">
		<script type='text/javascript'>
			$(function () {
				var focusfield = $('#supersearch');
				
				if (focusfield.length) {
					focusfield[0].focus();
					focusfield[0].select();
				}
			});
		</script>
	
							</div>
						<?php if (!isset($_GET['popup'])) { ?>
					</div>
				</main>
				
			</div>
		<?php } else { ?></div><?php } ?>
<?php if (!isset($_GET['popup'])) { ?><div class='fop-seal'></div><?php } ?></body></html><?php
    
  }


  
  

  
  
}



