Ik ben een complete ASP newbie, dat vooropgesteld...
Anyway, ik ben dus bezig met het ombouwen van het Snitz forum, (3.3.05 met Access database) naar een soort van simpel cms systeempje.
De Topics gebruik ik als document, en de forums heb ik zgn containers genoemd.
Op zich heb ik op die manier al een simpel CMS systeempje, behalve dat ik nog geen enkele vorm van versiebeheer heb.
In de originele versie worden de T_LAST_POST (datum/tijd) en de T_LAST_POST_AUTHOR (memberid) waarde in de database alleen geupdate als er een reply op het topic is.
Hoe precies, dat weet ik niet, maar ik zie het gebeuren in de database.
Als de originele initiele topicpost dus ge-edit wordt, wordt T_LAST_POST dus niet geupdate.
Nu wil ik dus dat deze waardes geupdate worden als er iets ge-edit is in het topic.
In het Snitz forum gaat het editen van een origineel topic via de methode MethodType = "EditTopic".
Dit gebeurt in het bestand post_info.asp.
Als ik in dit bestand kijk, zie ik nu het volgende:
Sorry, het is een hele lap tekst, en de layout wordt ook nog eens vernaggeld...
Maar, ik denk dus (ik ben een newbie...sorry) dat deze code de update zou moeten verzorgen:
Maar, ik weet dus niet waar ik dit zou moeten doen....
Iemand suggesties ?
Anyway, ik ben dus bezig met het ombouwen van het Snitz forum, (3.3.05 met Access database) naar een soort van simpel cms systeempje.
De Topics gebruik ik als document, en de forums heb ik zgn containers genoemd.
Op zich heb ik op die manier al een simpel CMS systeempje, behalve dat ik nog geen enkele vorm van versiebeheer heb.
In de originele versie worden de T_LAST_POST (datum/tijd) en de T_LAST_POST_AUTHOR (memberid) waarde in de database alleen geupdate als er een reply op het topic is.
Hoe precies, dat weet ik niet, maar ik zie het gebeuren in de database.
Als de originele initiele topicpost dus ge-edit wordt, wordt T_LAST_POST dus niet geupdate.
Nu wil ik dus dat deze waardes geupdate worden als er iets ge-edit is in het topic.
In het Snitz forum gaat het editen van een origineel topic via de methode MethodType = "EditTopic".
Dit gebeurt in het bestand post_info.asp.
Als ik in dit bestand kijk, zie ik nu het volgende:
code:
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
| if MethodType = "EditTopic" then
member = cint(ChkUser2(STRdbntUserName, Request.Form("Password"), strTopicAuthor))
select case Member
case 0 '## Invalid Pword
Go_Result "Invalid Password or UserName", 0
Response.End
case 1 '## Author of Post so OK
'## Do Nothing
case 2 '## Normal User - Not Authorised
Go_Result "Only Admins, Moderators and the Author can change this document", 0
Response.End
case 3 '## Moderator so
if chkForumModerator(Forum_ID, STRdbntUserName) = "0" then
Go_Result "Only Admins, Moderators and the Author can change this document", 0
end if
case 4 '## Admin so OK
'## Do Nothing
case else
Go_Result cstr(Member), 0
Response.End
end select
if Request.Form("isRTE")="true" then '############ RTE MOD CODE : VS 1.3 : 5 LINES
txtMessage = chkString(Replace(Request.Form("Message"), CHR(10), ""),"message")
else
txtMessage = chkString(Request.Form("Message"),"message")
end if '############ END RTE CODE
txtSubject = chkString(Request.Form("Subject"),"SQLString")
Err_Msg = ""
if txtSubject = " " then
Err_Msg = Err_Msg & "<li>You must enter a title for the document</li>"
end if
if txtMessage = " " then
Err_Msg = Err_Msg & "<li>You must enter a message for the document</li>"
end if
if Err_Msg = "" then
'unquote next line to disable edited by display for adminstrators
'if strEditedByDate = "1" and mlev < 4 then
'if strEditedByDate = "1" then
' txtMessage = txtMessage & vbNewline & vbNewline
"<small><br>This message is edited by "
' txtMessage = txtMessage & chkstring
(strDBNTUserName, "display") & " on " & chkDate(DateToStr(strForumTimeAdjust))
& " " & chkTime(DateToStr(strForumTimeAdjust)) & "</small>"
'end if
'## Set array to pull out CAT_ID and FORUM_ID from dropdown values in post.asp
aryForum = split(Request.Form("Forum"), "|")
'## if the forum we are moving to doesn't have MODERATION, and this topic did have that
'## we are going to have to auto-approve the topic !
AutoApprove = "No"
Moderation = "No"
if Forum_ID <> aryForum(1) then
blnTopicMoved = true
strSql = "Select " & strTablePrefix & "FORUM.F_MODERATION "
strSql = strsql & " FROM " & strTablePrefix & "FORUM "
strSql = strSql & " WHERE " & strTablePrefix & "FORUM.FORUM_ID = " & Forum_ID
set rsForumCheck = my_Conn.Execute (strSql)
ForumModeration = rsForumCheck("F_MODERATION")
rsForumCheck.Close
set rsForumCheck = nothing
'## Is Moderation allowed on the topic in the old forum ?
if (ForumModeration = 1 or ForumModeration = 2) then
Moderation = "Yes"
end if
if Moderation = "Yes" then
strSql = "Select " & strTablePrefix & "FORUM.F_MODERATION "
strSql = Strsql & " FROM " & strTablePrefix & "FORUM "
strSql = strSql & " WHERE " & strTablePrefix & "FORUM.FORUM_ID = " & aryForum(1)
set rsNewForumCheck = my_Conn.Execute (strSql)
NewForumModeration = rsNewForumCheck("F_MODERATION")
rsNewForumCheck.Close
set rsNewForumCheck = nothing
'## Is Moderation allowed on the topic in the new forum ?
if not(NewForumModeration = 1 or NewForumModeration = 2) then
AutoApprove = "Yes"
end if
end if
end if
'## Forum_SQL
strSql = "UPDATE " & strActivePrefix & "TOPICS "
strSql = strSql & " SET T_MESSAGE = '" & txtMessage & "'"
if blnTopicMoved then
strSql = strSql & ", CAT_ID = " & aryForum(0)
strSql = strSql & ", FORUM_ID = " & aryForum(1)
if AutoApprove = "Yes" then
strSql = strSql & ", T_STATUS = 1 "
end if
end if
strSql = strSql & " WHERE TOPIC_ID = " & Topic_ID
my_Conn.Execute(strSql)
if blnTopicMoved then
if strEmail = "1" and strMoveNotify = "1" then DoAutoMoveEmail(Topic_ID)
strSQL = "SELECT F_SUBSCRIPTION FROM " & strTablePrefix & "FORUM WHERE FORUM_ID=" & aryForum(1)
set rs = my_conn.execute (strSQL)
if rs("F_SUBSCRIPTION") < 3 then
strSQL = "DELETE FROM " & strTablePrefix & "SUBSCRIPTIONS WHERE TOPIC_ID=" & Topic_ID
my_conn.execute(strSQL)
end if
rs.close
end if
if Forum_ID <> aryForum(1) then
'## Forum_SQL
strSql = "UPDATE " & strActivePrefix & "REPLY "
strSql = strSql & " SET CAT_ID = " & aryForum(0)
strSql = strSql & ", FORUM_ID = " & aryForum(1)
strSql = strSql & " WHERE TOPIC_ID = " & Topic_ID
my_Conn.Execute(strSql)
set rs = Server.CreateObject("ADODB.Recordset")
'## if the topic hasn't been approved yet, it isn't counted either
'## so then the topic count doesn't need to be updated
if Moderation = "No" or AutoApprove = "Yes" then
'## Forum_SQL - count total number of replies in Topics table
strSql = "SELECT T_REPLIES, T_LAST_POST, T_LAST_POST_AUTHOR "
strSql = strSql & " FROM " & strActivePrefix & "TOPICS "
strSql = strSql & " WHERE TOPIC_ID = " & Topic_ID
set rs = my_Conn.Execute (strSql)
intResetCount = rs("T_REPLIES") + 1
strT_Last_Post = rs("T_LAST_POST")
strT_Last_Post_Author = rs("T_LAST_POST_AUTHOR")
rs.Close
set rs = nothing
'## Forum_SQL - Get last_post and last_post_author for MoveFrom-Forum
strSql = "SELECT T_LAST_POST, T_LAST_POST_AUTHOR "
strSql = strSql & " FROM " & strActivePrefix & "TOPICS "
strSql = strSql & " WHERE FORUM_ID = " & Forum_ID & " "
strSql = strSql & " ORDER BY T_LAST_POST DESC;"
set rs = my_Conn.Execute (strSql)
if not rs.eof then
strLast_Post = rs("T_LAST_POST")
strLast_Post_Author = rs("T_LAST_POST_AUTHOR")
else
strLast_Post = ""
strLast_Post_Author = ""
end if
rs.Close
set rs = nothing
if Moderation = "No" then
'## Forum_SQL - Update count of replies to a topic in Forum table
strSql = "UPDATE " & strTablePrefix & "FORUM SET "
strSql = strSql & " F_COUNT = F_COUNT - " & intResetCount
if strLast_Post <> "" then
strSql = strSql & ", F_LAST_POST = '" & strLast_Post & "'"
if strLast_Post_Author <> "" then
strSql = strSql & ", F_LAST_POST_AUTHOR = " & strLast_Post_Author
end if
end if
strSql = strSql & " WHERE FORUM_ID = " & Forum_ID
my_Conn.Execute(strSql)
'## Forum_SQL
strSql = "UPDATE " & strTablePrefix & "FORUM SET "
strSql = strSql & " F_TOPICS = F_TOPICS - 1 "
strSql = strSql & " WHERE FORUM_ID = " & Forum_ID
my_Conn.Execute(strSql)
end if
'## Forum_SQL - Get last_post and last_post_author for Forum
strSql = "SELECT T_LAST_POST, T_LAST_POST_AUTHOR, T_AUTHOR "
strSql = strSql & " FROM " & strActivePrefix & "TOPICS "
strSql = strSql & " WHERE FORUM_ID = " & aryForum(1) & " "
strSql = strSql & " ORDER BY T_LAST_POST DESC;"
set rs = my_Conn.Execute (strSql)
if not rs.eof then
strAuthor = getMemberName(strT_Last_Post_Author)
strLast_Post = rs("T_LAST_POST")
strLast_Post_Author = rs("T_LAST_POST_AUTHOR")
else
strAuthor = ""
strLast_Post = ""
strLast_Post_Author = ""
end if
rs.Close
set rs = nothing
'Huw -- Update member count
if (AutoApprove = "Yes") and blnTStatus = 2 and blnTopicMoved then
doUCount(strAuthor)
doULastPost(strAuthor)
end if
'## Forum_SQL - Update count of replies to a topic in Forum table
strSql = "UPDATE " & strTablePrefix & "FORUM SET "
strSql = strSql & " F_COUNT = (F_COUNT + " & intResetCount & ")"
if strLast_Post <> "" then
strSql = strSql & ", F_LAST_POST = '" & strLast_Post & "'"
if strLast_Post_Author <> "" then
strSql = strSql & ", F_LAST_POST_AUTHOR = " & strLast_Post_Author
end if
end if
strSql = strSql & " WHERE FORUM_ID = " & aryForum(1)
my_Conn.Execute(strSql)
'## Forum_SQL
strSql = "UPDATE " & strTablePrefix & "FORUM SET "
strSql = strSql & " F_TOPICS = F_TOPICS + 1 "
strSql = strSql & " WHERE FORUM_ID = " & aryForum(1)
my_Conn.Execute(strSql)
end if
'EXTRA CODE!!!!
'if mLev <> 4 and Moderation = "No" then
'## Forum_SQL - Update Last Post
strSql = " UPDATE " & strTablePrefix & "FORUM"
strSql = strSql & " SET F_LAST_POST = '" & DateToStr(strForumTimeAdjust) & "'"
strSql = strSql & ", F_LAST_POST_AUTHOR = " & getMemberID(STRdbntUserName)
strSql = strSql & " WHERE FORUM_ID = " & Forum_ID
my_Conn.Execute (strSql)
'## Forum_SQL - Update Last Post
strSql = " UPDATE " & strActivePrefix & "TOPICS"
strSql = strSql & " SET T_LAST_POST = '" & DateToStr(strForumTimeAdjust) & "'"
strSql = strSql & ", T_LAST_POST_AUTHOR = " & getMemberID(STRdbntUserName)
strSql = strSql & " WHERE TOPIC_ID = " & Topic_ID
my_Conn.Execute (strSql)
'end if
err_Msg = ""
if Err.description <> "" then
Go_Result "There was an error = " & Err.description, 0
Response.End
else
Go_Result "Updated OK", 1
end if
'## Forum_SQL
strSql = "UPDATE " & strActivePrefix & "TOPICS "
strSql = strSql & " SET T_LAST_POST = '" & DateToStr(strForumTimeAdjust) & "'"
strSql = strSql & ", T_LAST_POST_AUTHOR = " & getMemberID(STRdbntUserName)
strSql = strSql & " WHERE TOPIC_ID = " & Topic_ID
my_Conn.Execute (strSql)
err_Msg = ""
if Err.description <> "" then
Go_Result "There was an error = " & Err.description, 0
Response.End
else
Go_Result "Updated OK", 1
Response.End
end if
'EXTRA CODE
end if
err_Msg = ""
aryForum = ""
if Err.description <> "" then
Go_Result "There was an error = " & Err.description, 0
Response.End
else
Go_Result "Updated OK", 1
end if
else
%>
<p align=center><font face="<% =strDefaultFontFace %>" size="
<% =strHeaderFontSize %>">There Was A Problem With Your Details</font></p>
<table align=center border=0>
<tr>
<td><font face="<% =strDefaultFontFace %>" size="<% =strDefaultFontSize %>">
<ul>
<% =Err_Msg %>
</ul>
</font></td>
</tr>
</table>
<p align=center><font face="<% =strDefaultFontFace %>" size=
<% =strDefaultFontSize %>><a href="JavaScript:history.go(-1)">Go Back To Enter
Data</a></font></p>
<%
end if
end if |
Sorry, het is een hele lap tekst, en de layout wordt ook nog eens vernaggeld...
Maar, ik denk dus (ik ben een newbie...sorry) dat deze code de update zou moeten verzorgen:
code:
1
2
3
4
5
6
7
8
9
| '## Forum_SQL
strSql = "UPDATE " & strActivePrefix & "TOPICS "
strSql = strSql & " SET T_LAST_POST = '" & DateToStr(strForumTimeAdjust) & "'"
strSql = strSql & ", T_LAST_POST_AUTHOR = " & getMemberID(STRdbntUserName)
strSql = strSql & " WHERE TOPIC_ID = " & Topic_ID
my_Conn.Execute (strSql)
err_Msg = "" |
Maar, ik weet dus niet waar ik dit zou moeten doen....
Iemand suggesties ?
[ Voor 15% gewijzigd door MarcelG op 19-12-2002 13:01 . Reden: Layout was vernaggeld ]