Use short array syntax
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / acp / update_com.woltlab.wcf_3.0_post_sql.php
CommitLineData
c23634e7 1<?php
21656f26
MW
2use wcf\data\label\group\LabelGroupList;
3use wcf\data\label\LabelEditor;
4use wcf\data\label\LabelList;
5use wcf\data\template\group\TemplateGroupEditor;
6use wcf\data\template\group\TemplateGroupList;
7use wcf\util\exception\CryptoException;
8use wcf\util\CryptoUtil;
9use wcf\util\FileUtil;
96ad3d1d 10use wcf\system\WCF;
c23634e7 11
21656f26
MW
12// update label's show order
13$groupList = new LabelGroupList();
14$groupList->readObjects();
15foreach ($groupList as $group) {
16 $showOrder = 1;
17 $labelList = new LabelList();
18 $labelList->getConditionBuilder()->add('groupID = ?', [$group->groupID]);
19 $labelList->sqlOrderBy = 'label';
20 $labelList->readObjects();
21 foreach ($labelList as $label) {
22 $editor = new LabelEditor($label);
23 $editor->update(['showOrder' => $showOrder]);
24 $showOrder++;
25 }
26}
27// If a template group uses '_wcf_email' as the folder: Move it!
28$templateGroupList = new TemplateGroupList();
29$templateGroupList->getConditionBuilder()->add('templateGroupFolderName = ? AND templateGroupName <> ?', ['_wcf_email/', 'wcf.acp.template.group.email']);
30$templateGroupList->readObjects();
31foreach ($templateGroupList as $templateGroup) {
32 $i = 1;
33 do {
34 $newTemplateGroupFolderName = FileUtil::addTrailingSlash(FileUtil::removeTrailingSlash($templateGroup->templateGroupFolderName) . $i);
35 $i++;
36 }
37 while (file_exists(WCF_DIR . 'templates/' . $newTemplateGroupFolderName));
38
39 @rename(WCF_DIR . 'templates/' . $templateGroup->templateGroupFolderName, WCF_DIR . 'templates/' . $newTemplateGroupFolderName);
40 $editor = new TemplateGroupEditor($templateGroup);
41 $editor->update(['templateGroupFolderName' => $newTemplateGroupFolderName]);
42}
96ad3d1d 43
21656f26
MW
44// Fill in the mail_* constants with something sane.
45$sql = "UPDATE wcf".WCF_N."_option
46 SET optionValue = ?
47 WHERE optionName = ?";
48$statement = WCF::getDB()->prepareStatement($sql);
3531e368
MW
49if (!MAIL_FROM_NAME) {
50 $statement->execute([WCF::getUser()->username, 'mail_from_name']);
51}
52if (!MAIL_FROM_ADDRESS) {
53 $statement->execute([WCF::getUser()->email, 'mail_from_address']);
54}
55if (!MAIL_ADMIN_ADDRESS) {
56 $statement->execute([WCF::getUser()->email, 'mail_admin_address']);
57}
96ad3d1d 58
21656f26
MW
59// Generate signature_secret
60try {
61 $statement->execute([
62 bin2hex(CryptoUtil::randomBytes(20)),
63 'signature_secret'
64 ]);
65}
66catch (CryptoException $e) {
67 // ignore, the secret will stay empty and crypto operations
68 // depending on it will fail
69}
96ad3d1d 70
21656f26
MW
71// add vortex update servers if missing
72$serverURLs = [
73 'http://update.woltlab.com/vortex/',
74 'http://store.woltlab.com/vortex/'
75];
76foreach ($serverURLs as $serverURL) {
77 $sql = "SELECT COUNT(*) AS count
78 FROM wcf" . WCF_N . "_package_update_server
79 WHERE serverURL = ?";
80 $statement = WCF::getDB()->prepareStatement($sql);
81 $statement->execute([$serverURL]);
82 if (!$statement->fetchColumn()) {
83 $sql = "INSERT INTO wcf" . WCF_N . "_package_update_server
84 (serverURL)
85 VALUES (?)";
86 $statement = WCF::getDB()->prepareStatement($sql);
87 $statement->execute([$serverURL]);
88 }
89}
96ad3d1d
MW
90
91// set default landing page
92$sql = "UPDATE wcf".WCF_N."_page
93 SET isLandingPage = ?
94 WHERE identifier = ?";
95$statement = WCF::getDB()->prepareStatement($sql);
96$statement->execute([
97 1,
98 'com.woltlab.wcf.Dashboard'
99]);