From 448e1e569ca5eb0b8f3a2ae1640f50f7792d0f24 Mon Sep 17 00:00:00 2001
From: Xenomporio <>
Date: Thu, 23 Jun 2022 14:24:32 +0200
Subject: [PATCH] Minimal module implementation emailbackup -> to be replaced
by auto-generated module
---
www/pages/content/emailbackup_edit.tpl | 53 ++++++
www/pages/content/emailbackup_list.tpl | 20 +++
www/pages/emailbackup.php | 231 +++++++++++++++++++++++++
3 files changed, 304 insertions(+)
create mode 100644 www/pages/content/emailbackup_edit.tpl
create mode 100644 www/pages/content/emailbackup_list.tpl
create mode 100644 www/pages/emailbackup.php
diff --git a/www/pages/content/emailbackup_edit.tpl b/www/pages/content/emailbackup_edit.tpl
new file mode 100644
index 00000000..aa72758a
--- /dev/null
+++ b/www/pages/content/emailbackup_edit.tpl
@@ -0,0 +1,53 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/www/pages/content/emailbackup_list.tpl b/www/pages/content/emailbackup_list.tpl
new file mode 100644
index 00000000..8e05c210
--- /dev/null
+++ b/www/pages/content/emailbackup_list.tpl
@@ -0,0 +1,20 @@
+
+
+
+[MESSAGE]
+
+
+
+
+
+
+
+
+
+
+
+
+[POPUP]
diff --git a/www/pages/emailbackup.php b/www/pages/emailbackup.php
new file mode 100644
index 00000000..255ad028
--- /dev/null
+++ b/www/pages/emailbackup.php
@@ -0,0 +1,231 @@
+
+app=$app;
+ if($intern)return;
+
+ $this->app->ActionHandlerInit($this);
+
+ $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","Ü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ück zur Ü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ü');
+ $width = array('40%','50%', '10%');
+
+ $findcols = array('id','email', 'angezeigtername','ticket','emailbackup');
+ $searchsql = array('id','email', 'angezeigtername');
+
+ $defaultorder = 1;
+ $defaultorderdesc = 0;
+
+ $menu = "
";
+
+ $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;
+ }
+
+ $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', "
{|Benutzervorlage \"$benutzervorlage\" ist in Benutzung durch ".$usernames.".|}
");
+ } 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', "
Die Benutzervorlage \"$benutzervorlage\" wurde gelöscht.
");
+ }
+
+ $this->UservorlageList();
+ }
+
+ function UservorlageCreate()
+ {
+ $this->app->erp->MenuEintrag("index.php?module=uservorlage&action=list","Zurück zur Ü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.
';
+ }
+ 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', "
$error
");
+ else {
+
+ $id = $this->app->erp->CreateBenutzerVorlage($input);
+
+ $msg = $this->app->erp->base64_url_encode("
Die Benutzervorlage wurde erfolgreich angelegt.
");
+ header("Location: index.php?module=uservorlage&action=edit&id=$id&msg=$msg");
+ exit;
+ }
+ }
+
+ $this->SetInput($input);
+
+ $this->app->Tpl->Set('ACTIVCHECKED',"checked");
+ $this->app->Tpl->Set('VORRECHTE',"");
+ $extra = '
+ if($(\'#hwtoken\').val() == \'4\' || $(\'#hwtoken\').val() == \'5\')
+ {
+ message = \'\';
+ }
+ ';
+ $this->app->YUI->PasswordCheck('password', 'repassword', 'username', 'submit', $extra);
+ $this->app->Tpl->Parse('PAGE', "uservorlage_edit.tpl");
+ }
+
+ function EmailbackupEdit()
+ {
+ $id = $this->app->Secure->GetGET('id');
+ $this->app->Tpl->Set('ID', $id);
+
+ $this->app->erp->MenuEintrag("index.php?module=emailbackup&action=edit&id=$id","Details");
+ $this->app->erp->MenuEintrag("index.php?module=emailbackup&action=list","Zurück zur Übersicht");
+ $id = $this->app->Secure->GetGET('id');
+ $input = $this->GetInput();
+ $submit = $this->app->Secure->GetPOST('submitemailbackup');
+
+ // Input GET
+ if(is_numeric($id) && $submit!='') {
+ $error = '';
+ if ($input['bezeichnung']=='') {
+ $error .= 'Geben Sie bitte eine Bezeichnung ein.
';
+ }
+ else {
+
+ $this->app->DB->Update(
+ sprintf(
+ "UPDATE `uservorlage`
+ SET bezeichnung='%s',
+ beschreibung='%s'
+ WHERE id=%d
+ LIMIT 1",
+ $input['bezeichnung'],
+ $input['beschreibung'],
+ $id
+ )
+ );
+
+ $this->app->Tpl->Set('MESSAGE', "
Die Einstellungen wurden erfolgreich übernommen.
");
+ }
+ } // END Input Get
+
+ $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);
+
+ $this->app->Tpl->Parse('PAGE', "emailbackup_edit.tpl");
+ }
+
+ /**
+ * @return array
+ */
+ public function GetInput(): array
+ {
+ $input = array();
+ $input['EMAIL'] = $this->app->Secure->GetPOST('email');
+ $input['ANGEZEIGTERNAME'] = $this->app->Secure->GetPOST('angezeigtername');
+
+ return $input;
+ }
+
+ function SetInput($input)
+ {
+ $this->app->Tpl->Set('EMAIL', $input['email']);
+ $this->app->Tpl->Set('ANGEZEIGTERNAME', $input['angezeigtername']);
+ }
+
+}