-
Notifications
You must be signed in to change notification settings - Fork 19
/
pgsql_2.1.3_to_2.2.0.php
149 lines (116 loc) · 4.71 KB
/
pgsql_2.1.3_to_2.2.0.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
// Add `meta_description` and `meta_keywords` columns to the `storysubmission` table
$_SQL[] = "ALTER TABLE {$_TABLES['storysubmission']} ADD `meta_description` TEXT NULL AFTER `postmode`";
$_SQL[] = "ALTER TABLE {$_TABLES['storysubmission']} ADD `meta_keywords` TEXT NULL AFTER `meta_description`";
// Add `status_code` column to the `routes` table
$_SQL[] = "ALTER TABLE {$_TABLES['routes']} ADD `status_code` INT NOT NULL DEFAULT 200 AFTER `route`";
// Add `css_id` and `css_classes` columns to the `blocks` table
$_SQL[] = "ALTER TABLE {$_TABLES['blocks']} ADD `css_id` VARCHAR(255) NOT NULL DEFAULT '' AFTER `help`";
$_SQL[] = "ALTER TABLE {$_TABLES['blocks']} ADD `css_classes` VARCHAR(255) NOT NULL DEFAULT '' AFTER `css_id`";
// Drop small, read-only tables
$_SQL[] = "DROP TABLE {$_TABLES['commentcodes']}";
$_SQL[] = "DROP TABLE {$_TABLES['commentmodes']}";
$_SQL[] = "DROP TABLE {$_TABLES['featurecodes']}";
$_SQL[] = "DROP TABLE {$_TABLES['frontpagecodes']}";
$_SQL[] = "DROP TABLE {$_TABLES['postmodes']}";
$_SQL[] = "DROP TABLE {$_TABLES['sortcodes']}";
$_SQL[] = "DROP TABLE {$_TABLES['statuscodes']}";
$_SQL[] = "DROP TABLE {$_TABLES['trackbackcodes']}";
/**
* Upgrade Messages
*/
function upgrade_message213()
{
global $_TABLES;
// 3 upgrade message types exist 'information', 'warning', 'error'
// error type means the user cannot continue upgrade until fixed
// Comment signatures will be removed from old comments
$upgradeMessages['2.1.3'] = array(
'warning' => 18
);
return $upgradeMessages;
}
/**
* Add new config options
*/
function update_ConfValuesFor220()
{
global $_CONF, $_TABLES;
require_once $_CONF['path_system'] . 'classes/config.class.php';
$c = config::get_instance();
$me = 'Core';
// Add switch language redirect option
$c->add('switchlang_homepage',0,'select',6,28,0,370,TRUE, $me, 28);
// Add the cache_mobile config option again since the config option may be missing for sites who upgraded from 2.1.2 (upgrade script had a bug in it)
$c->add('cache_mobile',TRUE,'select',2,10,1,230,TRUE, $me, 10);
// Enable or disable Resource cache
$c->add('cache_resource',TRUE,'select',2,10,1,240,TRUE, $me, 10);
return true;
}
/**
* Add Theme Admin
*
* @return bool
*/
function addThemeAdminFor220()
{
global $_CONF, $_TABLES;
$sql1 = "INSERT INTO {$_TABLES['groups']} (grp_id, grp_name, grp_descr, grp_gl_core) "
. "VALUES (NULL, 'Theme Admin', 'Has full access to themes', 1)";
$sql2 = "INSERT INTO {$_TABLES['group_assignments']} (ug_main_grp_id, ug_grp_id) VALUES (%d, %d)";
$sql3 = "INSERT INTO {$_TABLES['features']} (ft_id, ft_name, ft_descr, ft_gl_core) "
. "VALUES (NULL, 'theme.edit', 'Access to theme settings', 1)";
$sql4 = "INSERT INTO {$_TABLES['access']} (acc_ft_id, acc_grp_id) VALUES (%d, %d)";
try {
DB_beginTransaction();
// Add Theme Admin to groups
if (!DB_query($sql1)) {
throw new \Exception(DB_error());
}
// Add Root group to Theme Admin group
$themeAdminGroupId = DB_insertId();
$rootGroupId = DB_getItem($_TABLES['groups'], 'grp_id', "grp_name = 'Root'");
$sql2 = sprintf($sql2, $themeAdminGroupId, $rootGroupId);
if (!DB_query($sql2)) {
throw new \Exception(DB_error());
}
// Add theme.edit feature
if (!DB_query($sql3)) {
throw new \Exception(DB_error());
}
// Assign theme.edit feature to Theme Admin
$themeAdminFeatureId = DB_insertId();
$sql4 = sprintf($sql4, $themeAdminFeatureId, $themeAdminGroupId);
if (!DB_query($sql4)) {
throw new \Exception(DB_error());
}
DB_commit();
} catch (\Exception $e) {
DB_rollBack();
return false;
}
return true;
}
/**
* Remove old Comment Signatures and User Edit Dates
*
* @return bool
*/
function removeCommentSig220()
{
global $_TABLES;
$sql = "SELECT cid, comment FROM {$_TABLES['comments']}
WHERE comment LIKE '%<!-- COMMENTSIG -->%'
OR comment LIKE '%<!-- /COMMENTEDIT -->%'";
$result = DB_query($sql);
$numRows = DB_numRows($result);
for ($i = 0; $i < $numRows; $i++) {
$A = DB_fetchArray($result);
$text = str_replace('<!-- COMMENTSIG --><div class="comment-sig">', '', $A['comment']);
$text = str_replace('</div><!-- /COMMENTSIG -->', '', $text);
$text = str_replace('<div class="comment-edit">', '', $text);
$text = str_replace('</div><!-- /COMMENTEDIT -->', '', $text);
DB_query("UPDATE {$_TABLES['comments']} SET comment = '$text' WHERE cid = {$A['cid']}");
}
return true;
}