change default template creation
This commit is contained in:
parent
3ebd801b3d
commit
f52ab69a5b
@ -3,7 +3,7 @@ function init_db_schema() {
|
|||||||
try {
|
try {
|
||||||
global $pdo;
|
global $pdo;
|
||||||
|
|
||||||
$db_version = "10112022_1146";
|
$db_version = "16112022_1325";
|
||||||
|
|
||||||
$stmt = $pdo->query("SHOW TABLES LIKE 'versions'");
|
$stmt = $pdo->query("SHOW TABLES LIKE 'versions'");
|
||||||
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
|
$num_results = count($stmt->fetchAll(PDO::FETCH_ASSOC));
|
||||||
@ -1366,30 +1366,36 @@ function init_db_schema() {
|
|||||||
"acl_app_passwds" => 1,
|
"acl_app_passwds" => 1,
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$stmt = $pdo->prepare("INSERT INTO `templates` (`type`, `template`, `attributes`)
|
$stmt = $pdo->prepare("SELECT id FROM `templates` WHERE `type` = :type AND `template` = :template");
|
||||||
SELECT :type, :template, :attributes FROM `templates`
|
|
||||||
WHERE NOT EXISTS (
|
|
||||||
SELECT `template` FROM `templates` WHERE `template` = :template2 AND `type` = :type2
|
|
||||||
) LIMIT 1;");
|
|
||||||
$stmt->execute(array(
|
$stmt->execute(array(
|
||||||
":type" => "domain",
|
":type" => "domain",
|
||||||
":type2" => "domain",
|
":template" => $default_domain_template["template"]
|
||||||
":template" => $default_domain_template["template"],
|
));
|
||||||
":template2" => $default_mailbox_template["template"],
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
":attributes" => json_encode($default_domain_template["attributes"])
|
if (empty($row)){
|
||||||
));
|
$stmt = $pdo->prepare("INSERT INTO `templates` (`type`, `template`, `attributes`)
|
||||||
$stmt = $pdo->prepare("INSERT INTO `templates` (`type`, `template`, `attributes`)
|
VALUES (:type, :template, :attributes)");
|
||||||
SELECT :type, :template, :attributes FROM `templates`
|
$stmt->execute(array(
|
||||||
WHERE NOT EXISTS (
|
":type" => "domain",
|
||||||
SELECT `template` FROM `templates` WHERE `template` = :template2 AND `type` = :type2
|
":template" => $default_domain_template["template"],
|
||||||
) LIMIT 1;");
|
":attributes" => json_encode($default_domain_template["attributes"])
|
||||||
|
));
|
||||||
|
}
|
||||||
|
$stmt = $pdo->prepare("SELECT id FROM `templates` WHERE `type` = :type AND `template` = :template");
|
||||||
$stmt->execute(array(
|
$stmt->execute(array(
|
||||||
":type" => "mailbox",
|
":type" => "mailbox",
|
||||||
":type2" => "mailbox",
|
":template" => $default_mailbox_template["template"]
|
||||||
":template" => $default_mailbox_template["template"],
|
|
||||||
":template2" => $default_mailbox_template["template"],
|
|
||||||
":attributes" => json_encode($default_mailbox_template["attributes"])
|
|
||||||
));
|
));
|
||||||
|
$row = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||||
|
if (empty($row)){
|
||||||
|
$stmt = $pdo->prepare("INSERT INTO `templates` (`type`, `template`, `attributes`)
|
||||||
|
VALUES (:type, :template, :attributes)");
|
||||||
|
$stmt->execute(array(
|
||||||
|
":type" => "mailbox",
|
||||||
|
":template" => $default_mailbox_template["template"],
|
||||||
|
":attributes" => json_encode($default_mailbox_template["attributes"])
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
if (php_sapi_name() == "cli") {
|
if (php_sapi_name() == "cli") {
|
||||||
echo "DB initialization completed" . PHP_EOL;
|
echo "DB initialization completed" . PHP_EOL;
|
||||||
|
Loading…
Reference in New Issue
Block a user