Skip to content

Commit cb0520b

Browse files
committed
Fixed: FS#833 - Subdomains doesn't follow when domain is changed.
1 parent f5e1895 commit cb0520b

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

interface/web/sites/web_domain_edit.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
/*
3-
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
3+
Copyright (c) 2007 - 2009, Till Brehm, projektfarm Gmbh
44
All rights reserved.
55
66
Redistribution and use in source and binary forms, with or without modification,
@@ -353,6 +353,18 @@ function onAfterUpdate() {
353353
$app->db->query($sql);
354354
}
355355

356+
//* If the domain name has been changed, we will have to change all subdomains
357+
if($this->dataRecord["domain"] != '' && $this->oldDataRecord["domain"] != '' && $this->dataRecord["domain"] != $this->oldDataRecord["domain"]) {
358+
$records = $app->db->queryAllRecords("SELECT domain_id,domain FROM web_domain WHERE type = 'subdomain' AND domain LIKE '%.".$app->db->quote($this->oldDataRecord["domain"])."'");
359+
foreach($records as $rec) {
360+
$subdomain = $app->db->quote(str_replace($this->oldDataRecord["domain"],$this->dataRecord["domain"],$rec['domain']));
361+
$app->db->datalogUpdate('web_domain', "domain = '".$subdomain."'", 'domain_id', $rec['domain_id']);
362+
}
363+
unset($records);
364+
unset($rec);
365+
unset($subdomain);
366+
}
367+
356368
}
357369

358370
function onAfterDelete() {

0 commit comments

Comments
 (0)