From 6c60b16422ba412ce238eba0be1aaf7dabb08851 Mon Sep 17 00:00:00 2001
From: Till Brehm <tbrehm@ispconfig.org>
Date: Thu, 26 May 2016 12:10:57 -0400
Subject: [PATCH] Proposed fix for #3929 (letsencrypt can not be activated when a new website gets created). Needs testing.
---
interface/web/sites/web_vhost_domain_edit.php | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/interface/web/sites/web_vhost_domain_edit.php b/interface/web/sites/web_vhost_domain_edit.php
index 3da4823..a007e31 100644
--- a/interface/web/sites/web_vhost_domain_edit.php
+++ b/interface/web/sites/web_vhost_domain_edit.php
@@ -50,6 +50,7 @@
class page_action extends tform_actions {
var $_vhostdomain_type = 'domain';
+ var $_letsencrypt_on_insert = false;
//* Returna a "3/2/1" path hash from a numeric id '123'
function id_hash($id, $levels) {
@@ -1333,6 +1334,18 @@
parent::onSubmit();
}
+
+ function onBeforeInsert() {
+ global $app, $conf;
+
+ // 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') {
+ $this->dataRecord['ssl_letsencrypt'] = 'n';
+ $this->_letsencrypt_on_insert = true;
+ }
+ }
+
function onAfterInsert() {
global $app, $conf;
@@ -1403,6 +1416,15 @@
$app->db->query($sql, $this->parent_domain_record['sys_groupid'], $system_user, $system_group, $document_root, $htaccess_allow_override, $php_open_basedir, $added_by, $this->id);
}
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)
+ if($this->_letsencrypt_on_insert == true) {
+ $tmp = $web_rec;
+ $tmp['ssl_letsencrypt'] = 'y';
+ $app->db->datalogUpdate('web_domain', $tmp, 'domain_id', $this->id);
+ unset($tmp);
+ }
+
}
function onBeforeUpdate () {
--
Gitblit v1.9.1