forked from vanilla/porter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
class.toast.php
177 lines (152 loc) · 4.63 KB
/
class.toast.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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
<?php
/**
* Toast (.NET) exporter tool
*
* @copyright Vanilla Forums Inc. 2013
* @license Proprietary
* @package VanillaPorter
*/
$Supported['toast'] = array('name'=> 'Toast', 'prefix'=>'tstdb_');
class Toast extends ExportController {
static $PasswordFormats = array(0 => 'md5', 1 => 'sha1', 2 => 'sha256', 3 => 'sha384', 4 => 'sha512');
/**
*
* @param ExportModel $Ex
*/
public function ForumExport($Ex) {
$CharacterSet = $Ex->GetCharacterSet('tstdb_Post');
if ($CharacterSet)
$Ex->CharacterSet = $CharacterSet;
$Ex->BeginExport('', 'Toast Forum');
$Ex->SourcePrefix = 'tstdb_';
// User.
$User_Map = array(
'ID' => 'UserID',
'Username' => 'Name',
'Email' => 'Email',
'LastLoginDate' => array('Column' => 'DateLastActive', 'Type' => 'datetime'),
'IP' => 'LastIPAddress'
);
$Ex->ExportTable('User', "
select
*,
NOW() as DateInserted
from :_Member u", $User_Map);
// Determine safe RoleID to use for non-existant Member role
$LastRoleID = 1001;
$LastRoleResult = $Ex->Query("select max(ID) as LastID from :_Group");
if ($LastRoleResult) {
$LastRole = mysql_fetch_array($LastRoleResult);
$LastRoleID = $LastRole['LastID'] + 1;
}
// Role.
// Add default Member role.
$Role_Map = array(
'ID' => 'RoleID',
'Name' => 'Name');
$Ex->ExportTable('Role', "
select
ID,
Name
from :_Group
union all
select
$LastRoleID as ID,
'Member' as Name
from :_Group;", $Role_Map);
// UserRole.
// Users without roles get put into new Member role.
$UserRole_Map = array(
'MemberID' => 'UserID',
'GroupID' => 'RoleID');
$Ex->ExportTable('UserRole', "
select
GroupID,
MemberID
from :_MemberGroupLink
union all
select
$LastRoleID as GroupID,
m.ID as MemberID
from :_Member m
left join :_MemberGroupLink l
on l.MemberID = m.ID
where l.GroupID is null", $UserRole_Map);
// Signatures.
$Ex->ExportTable('UserMeta', "
select
ID as UserID,
'Plugin.Signatures.Sig' as `Name`,
Signature as `Value`
from :_Member
where Signature <> ''
union all
select
ID as UserID,
'Plugin.Signatures.Format' as `Name`,
'BBCode' as `Value`
from :_Member
where Signature <> '';");
// Category.
$Category_Map = array(
'ID' => 'CategoryID',
'CategoryID' => 'ParentCategoryID',
'ForumName' => 'Name',
'Description' => 'Description');
$Ex->ExportTable('Category', "
select
f.ID,
f.CategoryID * 1000 as CategoryID,
f.ForumName,
f.Description
from :_Forum f
union all
select
c.ID * 1000 as ID,
-1 as CategoryID,
c.Name as ForumName,
null as Description
from :_Category c;", $Category_Map);
// Discussion.
$Discussion_Map = array(
'ID' => 'DiscussionID',
'ForumID' => 'CategoryID',
'MemberID' => 'InsertUserID',
'PostDate' => 'DateInserted',
'ModifyDate' => 'DateUpdated',
'LastPostDate' => 'DateLastComment',
'Subject' => 'Name',
'Message' => 'Body',
'Hits' => 'CountViews',
'ReplyCount' => 'CountComments'
);
$Ex->ExportTable('Discussion', "
select p.*,
'Html' as Format
from :_Post p
where p.Topic = 1
and p.Deleted = 0;", $Discussion_Map);
// Comment.
$Comment_Map = array(
'ID' => 'CommentID',
'TopicID' => 'DiscussionID',
'MemberID' => 'InsertUserID',
'PostDate' => 'DateInserted',
'ModifyDate' => 'DateUpdated',
'Message' => 'Body');
$Ex->ExportTable('Comment', "
select *,
'Html' as Format
from :_Post p
where Topic = 0 and Deleted = 0;", $Comment_Map);
$Ex->EndExport();
}
public function CleanDate($Value) {
if (!$Value)
return NULL;
if (substr($Value, 0, 4) == '0000')
return NULL;
return $Value;
}
}
?>