From 27972469e57a2072584470c3dadce83b6ddf8844 Mon Sep 17 00:00:00 2001
From: Till Brehm <tbrehm@ispconfig.org>
Date: Fri, 27 May 2016 13:07:09 -0400
Subject: [PATCH] Improved letsencrypt onInsert code.
---
interface/web/sites/web_vhost_domain_edit.php | 16 ++++++++++------
1 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/interface/web/sites/web_vhost_domain_edit.php b/interface/web/sites/web_vhost_domain_edit.php
index 09ff8ab..647061e 100644
--- a/interface/web/sites/web_vhost_domain_edit.php
+++ b/interface/web/sites/web_vhost_domain_edit.php
@@ -1342,8 +1342,12 @@
// Letsencrypt can not be activated before the website has been created
// So we deactivate it here and add a datalog update in onAfterInsert
if(isset($this->dataRecord['ssl_letsencrypt']) && $this->dataRecord['ssl_letsencrypt'] == 'y' && isset($this->dataRecord['ssl']) && $this->dataRecord['ssl'] == 'y') {
+ // Disable letsencrypt and ssl temporarily
$this->dataRecord['ssl_letsencrypt'] = 'n';
$this->dataRecord['ssl'] = 'n';
+ // Prevent that the datalog history gets written
+ $app->tform->formDef['db_history'] = 'no';
+ // Set variable that we check in onAfterInsert
$this->_letsencrypt_on_insert = true;
}
}
@@ -1419,13 +1423,13 @@
}
if(isset($this->dataRecord['folder_directive_snippets'])) $app->db->query("UPDATE web_domain SET folder_directive_snippets = ? WHERE domain_id = ?", $this->dataRecord['folder_directive_snippets'], $this->id);
- // Add a datalog update with letsencrypt enabled (see also onBeforeInsert)
+ // Add a datalog insert without letsencrypt and then an update with letsencrypt enabled (see also onBeforeInsert)
if($this->_letsencrypt_on_insert == true) {
- $tmp = $web_rec;
- $tmp['ssl_letsencrypt'] = 'y';
- $tmp['ssl'] = 'y';
- $app->db->datalogUpdate('web_domain', $tmp, 'domain_id', $this->id);
- unset($tmp);
+ $new_data_record = $app->tform->getDataRecord($this->id);
+ $app->tform->datalogSave('INSERT', $this->id, array(), $new_data_record);
+ $new_data_record['ssl_letsencrypt'] = 'y';
+ $new_data_record['ssl'] = 'y';
+ $app->db->datalogUpdate('web_domain', $new_data_record, 'domain_id', $this->id);
}
}
--
Gitblit v1.9.1