Skip to content

Commit 6c60b16

Browse files
author
Till Brehm
committed
Proposed fix for #3929 (letsencrypt can not be activated when a new website gets created). Needs testing.
1 parent 8b9b336 commit 6c60b16

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

interface/web/sites/web_vhost_domain_edit.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050

5151
class page_action extends tform_actions {
5252
var $_vhostdomain_type = 'domain';
53+
var $_letsencrypt_on_insert = false;
5354

5455
//* Returna a "3/2/1" path hash from a numeric id '123'
5556
function id_hash($id, $levels) {
@@ -1333,6 +1334,18 @@ function onSubmit() {
13331334

13341335
parent::onSubmit();
13351336
}
1337+
1338+
function onBeforeInsert() {
1339+
global $app, $conf;
1340+
1341+
// Letsencrypt can not be activated before the website has been created
1342+
// So we deactivate it here and add a datalog update in onAfterInsert
1343+
if(isset($this->dataRecord['ssl_letsencrypt']) && $this->dataRecord['ssl_letsencrypt'] == 'y') {
1344+
$this->dataRecord['ssl_letsencrypt'] = 'n';
1345+
$this->_letsencrypt_on_insert = true;
1346+
}
1347+
}
1348+
13361349

13371350
function onAfterInsert() {
13381351
global $app, $conf;
@@ -1403,6 +1416,15 @@ function onAfterInsert() {
14031416
$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);
14041417
}
14051418
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);
1419+
1420+
// Add a datalog update with letsencrypt enabled (see also onBeforeInsert)
1421+
if($this->_letsencrypt_on_insert == true) {
1422+
$tmp = $web_rec;
1423+
$tmp['ssl_letsencrypt'] = 'y';
1424+
$app->db->datalogUpdate('web_domain', $tmp, 'domain_id', $this->id);
1425+
unset($tmp);
1426+
}
1427+
14061428
}
14071429

14081430
function onBeforeUpdate () {

0 commit comments

Comments
 (0)