Primitive emailbackup module for editing email accounts

This commit is contained in:
Xenomporio 2022-06-26 18:26:37 +02:00
parent d59b7da9a2
commit d175dbc85e
3 changed files with 343 additions and 273 deletions

View File

@ -1,53 +1,96 @@
<!--<table border="0" width="100%">
<tr><td><table width="100%"><tr><td>[USER_CREATE]</td></tr></table></td></tr>
</table>-->
<style>
ul.ui-autocomplete {
/*padding-top:100px;*/
}
#trdummy {
height:0;
width:0;
overflow: hidden;
display:none;
}
</style>
<!-- gehort zu tabview -->
<div id="tabs">
<ul>
<li><a href="#tabs-1">{|E-Mailaccount|}</a></li>
<!-- <li><a href="#tabs-3">{|Rechte|}</a></li> -->
<li><a href="#tabs-1"></a></li>
</ul>
<!-- ende gehort zu tabview -->
<!-- erstes tab -->
<div id="tabs-1">
[MESSAGE]
<form enctype="multipart/form-data" action="" method="post" name="eprooform" id="usereditform">
[FORMHANDLEREVENT]
<table class="tableborder" border="0" cellpadding="3" cellspacing="0" width="100%">
<tbody>
<tr valign="top" colspan="3">
<td >
<fieldset><legend>{|E-Mailaccount|}</legend>
<table width="100%" border="0">
<tr><td>{|E-Mailadresse|}:*</td><td><input type="text" name="email" value="[EMAIL]" size="40"></td></tr>
<tr><td width="200">{|Angezeigter Name|}:</td><td><input type="text" name="angezeigtername" value="[ANGEZEIGTERNAME]" size="40"><i>{|Wird als Absendername angezeigt.|}</i></td></tr>
</table></fieldset>
</td></tr>
<tr valign="" height="" bgcolor="" align="" bordercolor="" class="klein" classname="klein">
<td width="" valign="" height="" bgcolor="" align="right" colspan="3" bordercolor="" classname="orange2" class="orange2">
<input type="submit" id="submit" name="submitemailbackup" value="Speichern" />
</tr>
</tbody>
</table>
</form>
<!-- Example for multiple tabs
<ul hidden">
<li><a href="#tabs-1">First Tab</a></li>
<li><a href="#tabs-2">Second Tab</a></li>
</ul>
-->
<div id="tabs-1">
[MESSAGE]
<form action="" method="post">
[FORMHANDLEREVENT]
<div class="row">
<div class="row-height">
<div class="col-xs-12 col-md-12 col-md-height">
<div class="inside inside-full-height">
<fieldset>
<legend>{|<!--Legend for this form area goes here>-->emailbackup|}</legend>
<table width="100%" border="0" class="mkTableFormular">
<tr><td>{|email|}:</td><td><input type="text" name="email" value="[EMAIL]" size="40"></td></tr>
<tr><td>{|angezeigtername|}:</td><td><input type="text" name="angezeigtername" value="[ANGEZEIGTERNAME]" size="40"></td></tr>
<tr><td>{|internebeschreibung|}:</td><td><input type="text" name="internebeschreibung" value="[INTERNEBESCHREIBUNG]" size="40"></td></tr>
<tr><td>{|benutzername|}:</td><td><input type="text" name="benutzername" value="[BENUTZERNAME]" size="40"></td></tr>
<tr><td>{|passwort|}:</td><td><input type="text" name="passwort" value="[PASSWORT]" size="40"></td></tr>
<tr><td>{|IMAP server|}:</td><td><input type="text" name="server" value="[SERVER]" size="40"></td></tr>
<tr><td>{|SMTP server|}:</td><td><input type="text" name="smtp" value="[SMTP]" size="40"></td></tr>
<tr><td>{|ticket|}:</td><td><input type="text" name="ticket" value="[TICKET]" size="40"></td></tr>
<tr><td>{|imap_sentfolder_aktiv|}:</td><td><input type="text" name="imap_sentfolder_aktiv" value="[IMAP_SENTFOLDER_AKTIV]" size="40"></td></tr>
<tr><td>{|imap_sentfolder|}:</td><td><input type="text" name="imap_sentfolder" value="[IMAP_SENTFOLDER]" size="40"></td></tr>
<tr><td>{|imap_port|}:</td><td><input type="text" name="imap_port" value="[IMAP_PORT]" size="40"></td></tr>
<tr><td>{|imap_type|}:</td><td><input type="text" name="imap_type" value="[IMAP_TYPE]" size="40"></td></tr>
<tr><td>{|autoresponder|}:</td><td><input type="text" name="autoresponder" value="[AUTORESPONDER]" size="40"></td></tr>
<tr><td>{|geschaeftsbriefvorlage|}:</td><td><input type="text" name="geschaeftsbriefvorlage" value="[GESCHAEFTSBRIEFVORLAGE]" size="40"></td></tr>
<tr><td>{|autoresponderbetreff|}:</td><td><input type="text" name="autoresponderbetreff" value="[AUTORESPONDERBETREFF]" size="40"></td></tr>
<tr><td>{|autorespondertext|}:</td><td><input type="text" name="autorespondertext" value="[AUTORESPONDERTEXT]" size="40"></td></tr>
<tr><td>{|projekt|}:</td><td><input type="text" name="projekt" value="[PROJEKT]" size="40"></td></tr>
<tr><td>{|emailbackup|}:</td><td><input type="text" name="emailbackup" value="[EMAILBACKUP]" size="40"></td></tr>
<tr><td>{|adresse|}:</td><td><input type="text" name="adresse" value="[ADRESSE]" size="40"></td></tr>
<tr><td>{|firma|}:</td><td><input type="text" name="firma" value="[FIRMA]" size="40"></td></tr>
<tr><td>{|loeschtage|}:</td><td><input type="text" name="loeschtage" value="[LOESCHTAGE]" size="40"></td></tr>
<tr><td>{|geloescht|}:</td><td><input type="text" name="geloescht" value="[GELOESCHT]" size="40"></td></tr>
<tr><td>{|ticketloeschen|}:</td><td><input type="text" name="ticketloeschen" value="[TICKETLOESCHEN]" size="40"></td></tr>
<tr><td>{|ticketabgeschlossen|}:</td><td><input type="text" name="ticketabgeschlossen" value="[TICKETABGESCHLOSSEN]" size="40"></td></tr>
<tr><td>{|ticketqueue|}:</td><td><input type="text" name="ticketqueue" value="[TICKETQUEUE]" size="40"></td></tr>
<tr><td>{|ticketprojekt|}:</td><td><input type="text" name="ticketprojekt" value="[TICKETPROJEKT]" size="40"></td></tr>
<tr><td>{|ticketemaileingehend|}:</td><td><input type="text" name="ticketemaileingehend" value="[TICKETEMAILEINGEHEND]" size="40"></td></tr>
<tr><td>{|smtp_extra|}:</td><td><input type="text" name="smtp_extra" value="[SMTP_EXTRA]" size="40"></td></tr>
<tr><td>{|smtp_ssl|}:</td><td><input type="text" name="smtp_ssl" value="[SMTP_SSL]" size="40"></td></tr>
<tr><td>{|smtp_port|}:</td><td><input type="text" name="smtp_port" value="[SMTP_PORT]" size="40"></td></tr>
<tr><td>{|smtp_frommail|}:</td><td><input type="text" name="smtp_frommail" value="[SMTP_FROMMAIL]" size="40"></td></tr>
<tr><td>{|smtp_fromname|}:</td><td><input type="text" name="smtp_fromname" value="[SMTP_FROMNAME]" size="40"></td></tr>
<tr><td>{|client_alias|}:</td><td><input type="text" name="client_alias" value="[CLIENT_ALIAS]" size="40"></td></tr>
<tr><td>{|smtp_authtype|}:</td><td><input type="text" name="smtp_authtype" value="[SMTP_AUTHTYPE]" size="40"></td></tr>
<tr><td>{|smtp_authparam|}:</td><td><input type="text" name="smtp_authparam" value="[SMTP_AUTHPARAM]" size="40"></td></tr>
<tr><td>{|smtp_loglevel|}:</td><td><input type="text" name="smtp_loglevel" value="[SMTP_LOGLEVEL]" size="40"></td></tr>
<tr><td>{|autosresponder_blacklist|}:</td><td><input type="text" name="autosresponder_blacklist" value="[AUTOSRESPONDER_BLACKLIST]" size="40"></td></tr>
<tr><td>{|eigenesignatur|}:</td><td><input type="text" name="eigenesignatur" value="[EIGENESIGNATUR]" size="40"></td></tr>
<tr><td>{|signatur|}:</td><td><input type="text" name="signatur" value="[SIGNATUR]" size="40"></td></tr>
<tr><td>{|mutex|}:</td><td><input type="text" name="mutex" value="[MUTEX]" size="40"></td></tr>
<tr><td>{|abdatum|}:</td><td><input type="text" name="abdatum" value="[ABDATUM]" size="40"></td></tr>
</table>
</fieldset>
</div>
</div>
</div>
</div>
<input type="submit" name="submit" value="Speichern" style="float:right"/>
</form>
</div>
<!-- Example for 2nd tab
<div id="tabs-2">
[MESSAGE]
<form action="" method="post">
[FORMHANDLEREVENT]
<div class="row">
<div class="row-height">
<div class="col-xs-12 col-md-12 col-md-height">
<div class="inside inside-full-height">
<fieldset>
<legend>{|...|}</legend>
<table width="100%" border="0" class="mkTableFormular">
...
</table>
</fieldset>
</div>
</div>
</div>
</div>
<input type="submit" name="submit" value="Speichern" style="float:right"/>
</form>
</div>
-->
</div>

View File

@ -1,20 +1,5 @@
<div id="tabs">
<ul><li><a href="#tabs-1"></a></li></ul>
<div id="tabs-1">
[MESSAGE]
<div class="row">
<div class="row-height">
<div class="col-xs-12 col-sm-12 col-sm-height">
<div class="inside inside-full-height">
<fieldset>
<legend></legend>
[ACCOUNT_TABLE]
</fieldset>
</div>
</div>
</div>
</div>
[MESSAGE]
[TAB1]
[TAB1NEXT]
</div>
</div>
[POPUP]

View File

@ -1,231 +1,273 @@
<?php
/*
**** COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
*
* Xentral (c) Xentral ERP Sorftware GmbH, Fuggerstrasse 11, D-86150 Augsburg, * Germany 2019
*
* This file is licensed under the Embedded Projects General Public License *Version 3.1.
*
* You should have received a copy of this license from your vendor and/or *along with this file; If not, please visit www.wawision.de/Lizenzhinweis
* to obtain the text of the corresponding license version.
*
**** END OF COPYRIGHT & LICENSE NOTICE *** DO NOT REMOVE ****
Copyright (c) 2022 Xenomporio project
*/
?>
<?php
* Copyright (c) 2022 Xenomporio project
*/
use Xentral\Components\Database\Exception\QueryFailureException;
class Emailbackup
{
function __construct($app, $intern = false)
{
$this->app=$app;
if($intern)return;
class Emailbackup {
$this->app->ActionHandlerInit($this);
function __construct($app, $intern = false) {
$this->app = $app;
if ($intern)
return;
$this->app->ActionHandler("create","EmailbackupCreate");
$this->app->ActionHandler("delete","EmailbackupDelete");
$this->app->ActionHandler("edit","EmailbackupEdit");
$this->app->ActionHandler("list","EmailbackupList");
$this->app->DefaultActionHandler("list");
//$this->Templates = $this->GetTemplates();
$this->app->ActionHandlerListen($app);
}
public function Install()
{
}
function EmailbackupList()
{
$this->app->erp->MenuEintrag("index.php?module=uservorlage&action=list","&Uuml;bersicht");
$this->app->erp->MenuEintrag("index.php?module=uservorlage&action=history","Historie");
$this->app->erp->MenuEintrag("index.php?module=uservorlage&action=create","Neue Benutzervorlage anlegen");
$this->app->erp->MenuEintrag("index.php?module=einstellungen&action=list","Zur&uuml;ck zur &Uuml;bersicht");
$this->app->YUI->TableSearch('ACCOUNT_TABLE','mailaccount_list',"show","","",basename(__FILE__), __CLASS__);
$this->app->Tpl->Parse('PAGE', "emailbackup_list.tpl");
}
static function TableSearch(&$app, $name, $erlaubtevars) {
switch ($name) {
case "mailaccount_list":
$allowed['mailaccount_list'] = array('list');
$heading = array('Adresse', 'Angezeigter Name','Ticket','Emailbackup', 'Men&uuml;');
$width = array('40%','50%', '10%');
$findcols = array('id','email', 'angezeigtername','ticket','emailbackup');
$searchsql = array('id','email', 'angezeigtername');
$defaultorder = 1;
$defaultorderdesc = 0;
$menu = "<table cellpadding=0 cellspacing=0><tr><td nowrap>"."<a href=\"index.php?module=emailbackup&action=edit&id=%value%\"><img src=\"./themes/{$app->Conf->WFconf['defaulttheme']}/images/edit.png\" border=\"0\"></a>&nbsp;<a href=\"#\" onclick=DeleteDialog(\"index.php?module=emailbackup&action=delete&id=%value%\");>" . "<img src=\"themes/{$app->Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\"></a>"."</td></tr></table>";
$sql = "SELECT id, email, angezeigtername, CASE WHEN ticket=1 THEN 'Ja' ELSE '' END, CASE WHEN emailbackup=1 THEN 'Ja' ELSE '' END, id FROM emailbackup";
// $where = "m.geloescht = 0";
$groupby = "";
// $count = "SELECT count(DISTINCT id) FROM emailbackup WHERE $where";
break;
$this->app->ActionHandlerInit($this);
$this->app->ActionHandler("list", "emailbackup_list");
$this->app->ActionHandler("create", "emailbackup_edit"); // This automatically adds a "New" button
$this->app->ActionHandler("edit", "emailbackup_edit");
$this->app->ActionHandler("delete", "emailbackup_delete");
$this->app->DefaultActionHandler("list");
$this->app->ActionHandlerListen($app);
}
$erg = false;
foreach($erlaubtevars as $k => $v)
{
if(isset($$v))$erg[$v] = $$v;
}
return $erg;
}
public function UservorlageDelete(): void
{
$id = (int)$this->app->Secure->GetGET('id');
$benutzervorlage = $this->app->DB->Select("SELECT bezeichnung FROM `uservorlage` WHERE id='$id' LIMIT 1");
$users = $this->app->DB->Select("SELECT `username` FROM `user` WHERE `vorlage` = '$benutzervorlage'");
$prefix = "\"";
if (!empty($users)) {
$usernames = "";
if (is_array($users)) {
foreach ($users as $user) {
$usernames = $usernames.$prefix.$user[0]."\"";
$prefix = ", \"";
}
} else {
$usernames = $users;
}
$this->app->Tpl->Set('MESSAGE', "<div class=\"error\">{|Benutzervorlage \"$benutzervorlage\" ist in Benutzung durch ".$usernames.".|}</div>");
} else {
$this->app->DB->Delete("DELETE FROM `uservorlage` WHERE `id` = '{$id}'");
$this->app->DB->Delete("DELETE FROM `uservorlagerights` WHERE `vorlage` = '{$id}'");
$this->app->Tpl->Set('MESSAGE', "<div class=\"error\">Die Benutzervorlage \"$benutzervorlage\" wurde gel&ouml;scht.</div>");
}
$this->UservorlageList();
}
function UservorlageCreate()
{
$this->app->erp->MenuEintrag("index.php?module=uservorlage&action=list","Zur&uuml;ck zur &Uuml;bersicht");
$input = $this->GetInput();
$submit = $this->app->Secure->GetPOST('submituservorlage');
$error = '';
$maxlightuser = 0;
if($submit!='') {
if($input['bezeichnung']=='') {
$error .= 'Geben Sie bitte einen Vorlagennamen ein.<br>';
}
if($this->app->DB->Select("SELECT '1' FROM `uservorlage` WHERE bezeichnung='{$input['bezeichnung']}' LIMIT 1")=='1') {
$error .= "Es existiert bereits eine Vorlage mit diesem Namen";
}
if($error!=='')
$this->app->Tpl->Set('MESSAGE', "<div class=\"error\">$error</div>");
else {
$id = $this->app->erp->CreateBenutzerVorlage($input);
$msg = $this->app->erp->base64_url_encode("<div class=\"success\">Die Benutzervorlage wurde erfolgreich angelegt.</div>");
header("Location: index.php?module=uservorlage&action=edit&id=$id&msg=$msg");
exit;
}
public function Install() {
/* Fill out manually later */
}
$this->SetInput($input);
static function TableSearch(&$app, $name, $erlaubtevars) {
switch ($name) {
case "emailbackup_list":
$allowed['emailbackup_list'] = array('list');
// $heading = array('angezeigtername', 'internebeschreibung', 'benutzername', 'passwort', 'server', 'smtp', 'ticket', 'imap_sentfolder_aktiv', 'imap_sentfolder', 'imap_port', 'imap_type', 'autoresponder', 'geschaeftsbriefvorlage', 'autoresponderbetreff', 'autorespondertext', 'projekt', 'emailbackup', 'adresse', 'firma', 'loeschtage', 'geloescht', 'ticketloeschen', 'ticketabgeschlossen', 'ticketqueue', 'ticketprojekt', 'ticketemaileingehend', 'smtp_extra', 'smtp_ssl', 'smtp_port', 'smtp_frommail', 'smtp_fromname', 'client_alias', 'smtp_authtype', 'smtp_authparam', 'smtp_loglevel', 'autosresponder_blacklist', 'eigenesignatur', 'signatur', 'mutex', 'abdatum', 'email', 'Men&uuml;');
$heading = array('email', 'angezeigtername', 'internebeschreibung', 'benutzername', 'server', 'smtp', 'ticket', 'emailbackup', 'Men&uuml;');
$width = array('10%'); // Fill out manually later
$this->app->Tpl->Set('ACTIVCHECKED',"checked");
$this->app->Tpl->Set('VORRECHTE',"<!--");
$this->app->Tpl->Set('NACHRECHTE',"-->");
$extra = '
if($(\'#hwtoken\').val() == \'4\' || $(\'#hwtoken\').val() == \'5\')
{
message = \'\';
$findcols = array('angezeigtername', 'internebeschreibung', 'benutzername', 'passwort', 'server', 'smtp', 'ticket', 'imap_sentfolder_aktiv', 'imap_sentfolder', 'imap_port', 'imap_type', 'autoresponder', 'geschaeftsbriefvorlage', 'autoresponderbetreff', 'autorespondertext', 'projekt', 'emailbackup', 'adresse', 'firma', 'loeschtage', 'geloescht', 'ticketloeschen', 'ticketabgeschlossen', 'ticketqueue', 'ticketprojekt', 'ticketemaileingehend', 'smtp_extra', 'smtp_ssl', 'smtp_port', 'smtp_frommail', 'smtp_fromname', 'client_alias', 'smtp_authtype', 'smtp_authparam', 'smtp_loglevel', 'autosresponder_blacklist', 'eigenesignatur', 'signatur', 'mutex', 'abdatum', 'email');
$searchsql = array('angezeigtername', 'internebeschreibung', 'benutzername', 'passwort', 'server', 'smtp', 'ticket', 'imap_sentfolder_aktiv', 'imap_sentfolder', 'imap_port', 'imap_type', 'autoresponder', 'geschaeftsbriefvorlage', 'autoresponderbetreff', 'autorespondertext', 'projekt', 'emailbackup', 'adresse', 'firma', 'loeschtage', 'geloescht', 'ticketloeschen', 'ticketabgeschlossen', 'ticketqueue', 'ticketprojekt', 'ticketemaileingehend', 'smtp_extra', 'smtp_ssl', 'smtp_port', 'smtp_frommail', 'smtp_fromname', 'client_alias', 'smtp_authtype', 'smtp_authparam', 'smtp_loglevel', 'autosresponder_blacklist', 'eigenesignatur', 'signatur', 'mutex', 'abdatum', 'email');
$defaultorder = 1;
$defaultorderdesc = 0;
$menu = "<table cellpadding=0 cellspacing=0><tr><td nowrap>" . "<a href=\"index.php?module=emailbackup&action=edit&id=%value%\"><img src=\"./themes/{$app->Conf->WFconf['defaulttheme']}/images/edit.png\" border=\"0\"></a>&nbsp;<a href=\"#\" onclick=DeleteDialog(\"index.php?module=emailbackup&action=delete&id=%value%\");>" . "<img src=\"themes/{$app->Conf->WFconf['defaulttheme']}/images/delete.svg\" border=\"0\"></a>" . "</td></tr></table>";
// $sql = "SELECT id, angezeigtername, internebeschreibung, benutzername, passwort, server, smtp, ticket, imap_sentfolder_aktiv, imap_sentfolder, imap_port, imap_type, autoresponder, geschaeftsbriefvorlage, autoresponderbetreff, autorespondertext, projekt, emailbackup, adresse, firma, loeschtage, geloescht, ticketloeschen, ticketabgeschlossen, ticketqueue, ticketprojekt, ticketemaileingehend, smtp_extra, smtp_ssl, smtp_port, smtp_frommail, smtp_fromname, client_alias, smtp_authtype, smtp_authparam, smtp_loglevel, autosresponder_blacklist, eigenesignatur, signatur, mutex, abdatum, email, id FROM emailbackup";
$sql = "SELECT id, email, angezeigtername, internebeschreibung, benutzername, server, smtp, ticket, emailbackup, id FROM emailbackup";
$where = "1";
$count = "SELECT count(DISTINCT id) FROM emailbackup WHERE $where";
// $groupby = "";
break;
}
$erg = false;
foreach ($erlaubtevars as $k => $v) {
if (isset($$v)) {
$erg[$v] = $$v;
}
}
return $erg;
}
';
$this->app->YUI->PasswordCheck('password', 'repassword', 'username', 'submit', $extra);
$this->app->Tpl->Parse('PAGE', "uservorlage_edit.tpl");
}
function emailbackup_list() {
$this->app->erp->MenuEintrag("index.php?module=emailbackup&action=list", "&Uuml;bersicht");
$this->app->erp->MenuEintrag("index.php?module=emailbackup&action=create", "Neu anlegen");
function EmailbackupEdit()
{
$id = $this->app->Secure->GetGET('id');
$this->app->Tpl->Set('ID', $id);
$this->app->erp->MenuEintrag("index.php?module=einstellungen&action=list", "Zur&uuml;ck");
$this->app->erp->MenuEintrag("index.php?module=emailbackup&action=edit&id=$id","Details");
$this->app->erp->MenuEintrag("index.php?module=emailbackup&action=list","Zur&uuml;ck zur &Uuml;bersicht");
$id = $this->app->Secure->GetGET('id');
$input = $this->GetInput();
$submit = $this->app->Secure->GetPOST('submitemailbackup');
$this->app->YUI->TableSearch('TAB1', 'emailbackup_list', "show", "", "", basename(__FILE__), __CLASS__);
$this->app->Tpl->Parse('PAGE', "emailbackup_list.tpl");
}
// Input GET
if(is_numeric($id) && $submit!='') {
$error = '';
if ($input['bezeichnung']=='') {
$error .= 'Geben Sie bitte eine Bezeichnung ein.<br>';
}
else {
$this->app->DB->Update(
sprintf(
"UPDATE `uservorlage`
SET bezeichnung='%s',
beschreibung='%s'
WHERE id=%d
LIMIT 1",
$input['bezeichnung'],
$input['beschreibung'],
$id
)
);
public function emailbackup_delete() {
$id = (int) $this->app->Secure->GetGET('id');
$this->app->DB->Delete("DELETE FROM `emailbackup` WHERE `id` = '{$id}'");
$this->app->Tpl->Set('MESSAGE', "<div class=\"error\">Der Eintrag wurde gel&ouml;scht.</div>");
$this->app->Tpl->Set('MESSAGE', "<div class=\"success\">Die Einstellungen wurden erfolgreich &uuml;bernommen.</div>");
}
} // END Input Get
$this->emailbackup_list();
}
$email = $this->app->DB->Select("SELECT email FROM `emailbackup` WHERE id='$id' LIMIT 1");
$angezeigtername = $this->app->DB->Select("SELECT angezeigtername FROM `emailbackup` WHERE id='$id' LIMIT 1");
$this->app->Tpl->Add('KURZUEBERSCHRIFT2',$email);
$this->app->Tpl->Add('EMAIL',$email);
$this->app->Tpl->Add('ANGEZEIGTERNAME',$angezeigtername);
/*
* Edit emailbackup item
* If id is empty, create a new one
*/
function emailbackup_edit() {
$id = $this->app->Secure->GetGET('id');
$this->app->Tpl->Set('ID', $id);
$this->app->Tpl->Parse('PAGE', "emailbackup_edit.tpl");
}
$this->app->erp->MenuEintrag("index.php?module=emailbackup&action=edit&id=$id", "Details");
$this->app->erp->MenuEintrag("index.php?module=emailbackup&action=list", "Zur&uuml;ck zur &Uuml;bersicht");
$id = $this->app->Secure->GetGET('id');
$input = $this->GetInput();
$submit = $this->app->Secure->GetPOST('submit');
if (empty($id)) {
// New item
$id = 'NULL';
}
/**
* @return array
*/
public function GetInput(): array
{
$input = array();
$input['EMAIL'] = $this->app->Secure->GetPOST('email');
$input['ANGEZEIGTERNAME'] = $this->app->Secure->GetPOST('angezeigtername');
if ($submit != '')
{
return $input;
}
// Write to database
// Add checks here
function SetInput($input)
{
$this->app->Tpl->Set('EMAIL', $input['email']);
$this->app->Tpl->Set('ANGEZEIGTERNAME', $input['angezeigtername']);
}
$columns = "id, ";
$values = "$id, ";
$update = "";
$fix = "";
foreach ($input as $key => $value) {
$columns = $columns.$fix.$key;
$values = $values.$fix."'".$value."'";
$update = $update.$fix.$key." = '$value'";
$fix = ", ";
}
// echo($columns."<br>");
// echo($values."<br>");
// echo($update."<br>");
$email_exists = $this->app->DB->Select("SELECT id FROM emailbackup WHERE email='".$input['email']."'");
if ($id == 'NULL' && !empty($email_exists)) {
$this->app->Tpl->Set('MESSAGE', "<div class=\"error\">Account existiert bereits!</div>");
$this->SetInput($input);
$this->app->Tpl->Parse('PAGE', "emailbackup_edit.tpl");
return;
}
else {
$sql = "INSERT INTO emailbackup (".$columns.") VALUES (".$values.") ON DUPLICATE KEY UPDATE ".$update;
$this->app->DB->Update($sql);
if ($id == 'NULL') {
$msg = $this->app->erp->base64_url_encode("<div class=\"success\">Das Element wurde erfolgreich angelegt.</div>");
header("Location: index.php?module=emailbackup&action=list&msg=$msg");
} else {
$this->app->Tpl->Set('MESSAGE', "<div class=\"success\">Die Einstellungen wurden erfolgreich &uuml;bernommen.</div>");
}
} // New account
} // Submit
// Load values again from database
$result = $this->app->DB->SelectArr("SELECT id, angezeigtername, internebeschreibung, benutzername, passwort, server, smtp, ticket, imap_sentfolder_aktiv, imap_sentfolder, imap_port, imap_type, autoresponder, geschaeftsbriefvorlage, autoresponderbetreff, autorespondertext, projekt, emailbackup, adresse, firma, loeschtage, geloescht, ticketloeschen, ticketabgeschlossen, ticketqueue, ticketprojekt, ticketemaileingehend, smtp_extra, smtp_ssl, smtp_port, smtp_frommail, smtp_fromname, client_alias, smtp_authtype, smtp_authparam, smtp_loglevel, autosresponder_blacklist, eigenesignatur, signatur, mutex, abdatum, email, id FROM emailbackup"." WHERE id=$id");
foreach ($result[0] as $key => $value) {
$this->app->Tpl->Set(strtoupper($key), $value);
}
/*
* Add displayed items later
*
$this->app->Tpl->Add('KURZUEBERSCHRIFT2', $email);
$this->app->Tpl->Add('EMAIL', $email);
$this->app->Tpl->Add('ANGEZEIGTERNAME', $angezeigtername);
*/
$this->app->Tpl->Parse('PAGE', "emailbackup_edit.tpl");
}
/**
* Get all paramters from html form and save into $input
*/
public function GetInput(): array {
$input = array();
//$input['EMAIL'] = $this->app->Secure->GetPOST('email');
$input['angezeigtername'] = $this->app->Secure->GetPOST('angezeigtername');
$input['internebeschreibung'] = $this->app->Secure->GetPOST('internebeschreibung');
$input['benutzername'] = $this->app->Secure->GetPOST('benutzername');
$input['passwort'] = $this->app->Secure->GetPOST('passwort');
$input['server'] = $this->app->Secure->GetPOST('server');
$input['smtp'] = $this->app->Secure->GetPOST('smtp');
$input['ticket'] = $this->app->Secure->GetPOST('ticket');
$input['imap_sentfolder_aktiv'] = $this->app->Secure->GetPOST('imap_sentfolder_aktiv');
$input['imap_sentfolder'] = $this->app->Secure->GetPOST('imap_sentfolder');
$input['imap_port'] = $this->app->Secure->GetPOST('imap_port');
$input['imap_type'] = $this->app->Secure->GetPOST('imap_type');
$input['autoresponder'] = $this->app->Secure->GetPOST('autoresponder');
$input['geschaeftsbriefvorlage'] = $this->app->Secure->GetPOST('geschaeftsbriefvorlage');
$input['autoresponderbetreff'] = $this->app->Secure->GetPOST('autoresponderbetreff');
$input['autorespondertext'] = $this->app->Secure->GetPOST('autorespondertext');
$input['projekt'] = $this->app->Secure->GetPOST('projekt');
$input['emailbackup'] = $this->app->Secure->GetPOST('emailbackup');
$input['adresse'] = $this->app->Secure->GetPOST('adresse');
$input['firma'] = $this->app->Secure->GetPOST('firma');
$input['loeschtage'] = $this->app->Secure->GetPOST('loeschtage');
$input['geloescht'] = $this->app->Secure->GetPOST('geloescht');
$input['ticketloeschen'] = $this->app->Secure->GetPOST('ticketloeschen');
$input['ticketabgeschlossen'] = $this->app->Secure->GetPOST('ticketabgeschlossen');
$input['ticketqueue'] = $this->app->Secure->GetPOST('ticketqueue');
$input['ticketprojekt'] = $this->app->Secure->GetPOST('ticketprojekt');
$input['ticketemaileingehend'] = $this->app->Secure->GetPOST('ticketemaileingehend');
$input['smtp_extra'] = $this->app->Secure->GetPOST('smtp_extra');
$input['smtp_ssl'] = $this->app->Secure->GetPOST('smtp_ssl');
$input['smtp_port'] = $this->app->Secure->GetPOST('smtp_port');
$input['smtp_frommail'] = $this->app->Secure->GetPOST('smtp_frommail');
$input['smtp_fromname'] = $this->app->Secure->GetPOST('smtp_fromname');
$input['client_alias'] = $this->app->Secure->GetPOST('client_alias');
$input['smtp_authtype'] = $this->app->Secure->GetPOST('smtp_authtype');
$input['smtp_authparam'] = $this->app->Secure->GetPOST('smtp_authparam');
$input['smtp_loglevel'] = $this->app->Secure->GetPOST('smtp_loglevel');
$input['autosresponder_blacklist'] = $this->app->Secure->GetPOST('autosresponder_blacklist');
$input['eigenesignatur'] = $this->app->Secure->GetPOST('eigenesignatur');
$input['signatur'] = $this->app->Secure->GetPOST('signatur');
$input['mutex'] = $this->app->Secure->GetPOST('mutex');
$input['abdatum'] = $this->app->Secure->GetPOST('abdatum');
$input['email'] = $this->app->Secure->GetPOST('email');
return $input;
}
/*
* Set all fields in the page corresponding to $input
*/
function SetInput($input) {
// $this->app->Tpl->Set('EMAIL', $input['email']);
$this->app->Tpl->Set('ANGEZEIGTERNAME', $input['angezeigtername']);
$this->app->Tpl->Set('INTERNEBESCHREIBUNG', $input['internebeschreibung']);
$this->app->Tpl->Set('BENUTZERNAME', $input['benutzername']);
$this->app->Tpl->Set('PASSWORT', $input['passwort']);
$this->app->Tpl->Set('SERVER', $input['server']);
$this->app->Tpl->Set('SMTP', $input['smtp']);
$this->app->Tpl->Set('TICKET', $input['ticket']);
$this->app->Tpl->Set('IMAP_SENTFOLDER_AKTIV', $input['imap_sentfolder_aktiv']);
$this->app->Tpl->Set('IMAP_SENTFOLDER', $input['imap_sentfolder']);
$this->app->Tpl->Set('IMAP_PORT', $input['imap_port']);
$this->app->Tpl->Set('IMAP_TYPE', $input['imap_type']);
$this->app->Tpl->Set('AUTORESPONDER', $input['autoresponder']);
$this->app->Tpl->Set('GESCHAEFTSBRIEFVORLAGE', $input['geschaeftsbriefvorlage']);
$this->app->Tpl->Set('AUTORESPONDERBETREFF', $input['autoresponderbetreff']);
$this->app->Tpl->Set('AUTORESPONDERTEXT', $input['autorespondertext']);
$this->app->Tpl->Set('PROJEKT', $input['projekt']);
$this->app->Tpl->Set('EMAILBACKUP', $input['emailbackup']);
$this->app->Tpl->Set('ADRESSE', $input['adresse']);
$this->app->Tpl->Set('FIRMA', $input['firma']);
$this->app->Tpl->Set('LOESCHTAGE', $input['loeschtage']);
$this->app->Tpl->Set('GELOESCHT', $input['geloescht']);
$this->app->Tpl->Set('TICKETLOESCHEN', $input['ticketloeschen']);
$this->app->Tpl->Set('TICKETABGESCHLOSSEN', $input['ticketabgeschlossen']);
$this->app->Tpl->Set('TICKETQUEUE', $input['ticketqueue']);
$this->app->Tpl->Set('TICKETPROJEKT', $input['ticketprojekt']);
$this->app->Tpl->Set('TICKETEMAILEINGEHEND', $input['ticketemaileingehend']);
$this->app->Tpl->Set('SMTP_EXTRA', $input['smtp_extra']);
$this->app->Tpl->Set('SMTP_SSL', $input['smtp_ssl']);
$this->app->Tpl->Set('SMTP_PORT', $input['smtp_port']);
$this->app->Tpl->Set('SMTP_FROMMAIL', $input['smtp_frommail']);
$this->app->Tpl->Set('SMTP_FROMNAME', $input['smtp_fromname']);
$this->app->Tpl->Set('CLIENT_ALIAS', $input['client_alias']);
$this->app->Tpl->Set('SMTP_AUTHTYPE', $input['smtp_authtype']);
$this->app->Tpl->Set('SMTP_AUTHPARAM', $input['smtp_authparam']);
$this->app->Tpl->Set('SMTP_LOGLEVEL', $input['smtp_loglevel']);
$this->app->Tpl->Set('AUTOSRESPONDER_BLACKLIST', $input['autosresponder_blacklist']);
$this->app->Tpl->Set('EIGENESIGNATUR', $input['eigenesignatur']);
$this->app->Tpl->Set('SIGNATUR', $input['signatur']);
$this->app->Tpl->Set('MUTEX', $input['mutex']);
$this->app->Tpl->Set('ABDATUM', $input['abdatum']);
$this->app->Tpl->Set('EMAIL', $input['email']);
}
}