%
' Discussions CustomIncludes begin
%>
<%
sFileName = "Discussions.asp"
sTemplateFileName = "Discussions.html"
' Discussions Open Event begin
'''''if GetParam("forum_id")="" then response.redirect("Forums.asp")
If GetParam("admin") <> "" then
Session("UserID")= "6"
Session("UserRights")= 6
else
Session("UserID")= Empty
Session("UserRights")= Empty
End If
'-------------------------------
sAction = GetParam("FormAction")
sForm = GetParam("FormName")
'-------------------------------
LoadTemplate sAppPath & sTemplateFileName, "main"
'-------------------------------
SetVar "FileName", sFileName
'-------------------------------
Search_Show
Discussions_Show
'-------------------------------
Parse "main", False
' Output the page to the browser
Response.write PrintVar("main")
' Destroy all object variables
cn.Close
Set cn = Nothing
UnloadTemplate
' Display Grid Form
'-------------------------------
Sub Discussions_Show()
'-------------------------------
Dim rs
Dim sWhere : sWhere = ""
Dim sOrder : sOrder = ""
Dim sSQL : sSQL = ""
Dim sFormTitle: sFormTitle = ""
Dim HasParam : HasParam = false
Dim iSort : iSort = ""
Dim iSorted : iSorted = ""
Dim sDirection : sDirection = ""
Dim sSortParams : sSortParams = ""
Dim iRecordsPerPage : iRecordsPerPage = 10
Dim iCounter : iCounter = 0
Dim iPage : iPage = 0
Dim bEof : bEof = False
Dim sActionFileName : sActionFileName = "DiscEdit.asp"
SetVar "TransitParams", "forum_id=" & ToURL(GetParam("forum_id")) & "&s_topic=" & ToURL(GetParam("s_topic")) & "&"
SetVar "FormParams", "forum_id=" & ToURL(GetParam("forum_id")) & "&s_topic=" & ToURL(GetParam("s_topic")) & "&"
'********** üst kısım yanıtlar başlangıcı **************
sSQL = "select top 3 [m].[message_author] as m_message_author, " & _
"[m].[message_topic] as m_message_topic, " & _
"[m].[message_id] as m_message_id, " & _
"[m].[message_parent_id] as m_message_parent_id, " & _
"[m].[message_date_entered] as m_message_date_entered " & _
" from [messages] m WHERE (ONAY= TRUE)" & _
" order by m.[message_date_entered] DESC"
openrs rs, sSQL
if not rs.eof then
while not rs.EOF
'-------------------------------
fldmauthor = GetValue(rs, "m_message_author")
fldmid = GetValue(rs, "m_message_id")
fldPmid = GetValue(rs, "m_message_parent_id")
fldmdate = GetValue(rs, "m_message_date_entered")
fldmtopic_URLLink = "DiscView.asp"
fldmtopic = GetValue(rs, "m_message_topic")
'-------------------------------
SetVar "mauthor", ToHTML(fldmauthor)
if fldPmid <> "" then
SetVar "mid", ToHTML(fldPmid)
else
SetVar "mid", ToHTML(fldmid)
end if
SetVar "mdate", ToHTML(fldmdate)
SetVar "mtopic_URLLink", fldmtopic_URLLink
SetVar "mtopic", ToHTML(fldmtopic)
Parse "DListMessages", True
rs.MoveNext
wend
sSQL=""
end if
'********** üst kısım yanıtlar sonu **************
' Build WHERE statement
pforum_id = 1'GetParam("forum_id") !!!!!!!!!!
if IsNumeric(pforum_id) and not isEmpty(pforum_id) then pforum_id = ToSQL(pforum_id, "Number") else pforum_id = Empty
if not isEmpty(pforum_id) then
HasParam = true
sWhere = sWhere & "m.[forum_id]=" & pforum_id
end if
ps_topic = GetParam("s_topic")
if not isEmpty(ps_topic) then
if not (sWhere = "") then sWhere = sWhere & " and "
HasParam = true
sWhere = sWhere & "m.[message_topic] like '%" & replace(ps_topic, "'", "''") & "%'"
end if
ps_topic = GetParam("s_topic")
if not isEmpty(ps_topic) then
if not (sWhere = "") then sWhere = sWhere & " and "
HasParam = true
sWhere = sWhere & "m.[message_content] like '%" & replace(ps_topic, "'", "''") & "%'"
end if
if HasParam then
sWhere = " WHERE (message_parent_id is null or message_parent_id=0) AND (" & sWhere & ") AND (ONAY= true)"
else
sWhere = " WHERE message_parent_id is null or message_parent_id=0 AND (ONAY= true)"
end if
'-------------------------------
' Build ORDER BY statement
'-------------------------------
sOrder = " order by m.message_last_reply_date Desc"
' sOrder = " order by m.message_id Desc"
iSort = GetParam("FormDiscussions_Sorting")
iSorted = GetParam("FormDiscussions_Sorted")
sDirection = ""
if IsEmpty(iSort) then
SetVar "Form_Sorting", ""
else
if iSort = iSorted then
SetVar "Form_Sorting", ""
sDirection = " DESC"
sSortParams = "FormDiscussions_Sorting=" & iSort & "&FormDiscussions_Sorted=" & iSort & "&"
else
SetVar "Form_Sorting", iSort
sDirection = " ASC"
sSortParams = "FormDiscussions_Sorting=" & iSort & "&FormDiscussions_Sorted=" & "&"
end if
if iSort = 1 then sOrder = " order by m.[message_topic]" & sDirection
if iSort = 2 then sOrder = " order by m.[message_author]" & sDirection
if iSort = 3 then sOrder = " order by m.[message_child_count]" & sDirection
if iSort = 4 then sOrder = " order by m.[message_last_reply_date]" & sDirection
end if
'-------------------------------
' Build base SQL statement
'-------------------------------
sSQL = "select [m].[forum_id] as m_forum_id, " & _
"[m].[member_id_author] as m_member_id_author, " & _
"[m].[message_author] as m_message_author, " & _
"[m].[message_child_count] as m_message_child_count, " & _
"[m].[message_content] as m_message_content, " & _
"[m].[message_id] as m_message_id, " & _
"[m].[message_last_reply_date] as m_message_last_reply_date, " & _
"[m].[message_topic] as m_message_topic " & _
" from [messages] m "
' "[f].[forum_name] as f_forum_name " & _
' " from [messages] m, [forums] f" & _
' " where [f].[forum_id]=m.[forum_id] "
'-------------------------------
'-------------------------------
' disabled at 22.10.2004
' moderator=dlookup("forums","member_id_moderator","forum_id=" & getParam("forum_id"))
'-------------------------------
' Assemble full SQL statement
'-------------------------------
sSQL = sSQL & sWhere & sOrder
'-------------------------------
SetVar "FormTitle", sFormTitle
SetVar "forum_adi", dlookup("forums","forum_name","forum_id=" & pforum_id)
'-------------------------------
SetVar "FormAction", sActionFileName
'-------------------------------
SetVar "SortParams", sSortParams
' Open the recordset
'-------------------------------
openrs rs, sSQL
'-------------------------------
'-------------------------------
' Process empty recordset
'-------------------------------
if rs.eof then
set rs = nothing
SetVar "DListDiscussions", ""
Parse "DiscussionsNoRecords", False
SetVar "DiscussionsNavigator", ""
Parse "FormDiscussions", False
exit sub
end if
'-------------------------------
'-------------------------------
' Initialize page counter and records per page
'-------------------------------
iRecordsPerPage = 30
iCounter = 0
'-------------------------------
'-------------------------------
' Process page scroller
'-------------------------------
iPage = GetParam("FormDiscussions_Page")
if IsEmpty(iPage) then iPage = 1 else iPage = CLng(iPage)
while not rs.eof and iCounter < (iPage-1)*iRecordsPerPage
rs.movenext
iCounter = iCounter + 1
wend
iCounter = 0
'-------------------------------
'-------------------------------
' Display grid based on recordset
'-------------------------------
while not rs.EOF and iCounter < iRecordsPerPage
'-------------------------------
' Create field variables based on database fields
'-------------------------------
fldforum_id = GetValue(rs, "m_forum_id")
fldmember_id_author = GetValue(rs, "m_member_id_author")
fldmauthor = GetValue(rs, "m_message_author")
fldmcount = GetValue(rs, "m_message_child_count")
fldmid = GetValue(rs, "m_message_id")
fldmdate = GetValue(rs, "m_message_last_reply_date")
fldmtopic_URLLink = "DiscView.asp"
fldmtopic_mid = GetValue(rs, "m_message_id")
fldmtopic_forum_id = GetValue(rs, "m_forum_id")
fldmtopic = GetValue(rs, "m_message_topic")
'-------------------------------
' Discussions Show begin
fldedit=""
'if (fldmember_id_author<>"" and fldmember_id_author=cint(Session("UserID"))) or cint(Session("UserID"))=moderator then fldedit="edit"
if Session("UserID")<>"" and Session("UserRights") > 2 then fldedit="
Düzenle"
'if fldmcount > 0 then fldField1 = "
" else fldField1="
"
'-------------------------------
' Replace Template fields with database values
'-------------------------------
' SetVar "forum_adi", forum_adi
SetVar "Field1", fldField1
SetVar "mid", ToHTML(fldmid)
SetVar "mtopic", ToHTML(fldmtopic)
SetVar "mtopic_URLLink", fldmtopic_URLLink
SetVar "Prmmtopic_mid", ToURL(fldmtopic_mid)
SetVar "Prmmtopic_forum_id", ToURL(fldmtopic_forum_id)
SetVar "mauthor", ToHTML(fldmauthor)
SetVar "mdate", ToHTML(fldmdate)
'burada son yazar adı eklendi
dim MySQL
dim MyRs
MySQL = "select max(message_id) " & _
"from messages where onay= true and message_parent_id =" & ToHTML(fldmid)
openrs MyRs, MySQL
FldMsgId = GetValue(MyRs, 0)
fldmyazar = DLookup("messages","message_author","message_id =" & FldMsgId )
SetVar "sonyazar", ToHTML(fldmyazar)
' SetVar "myazar", dlookup("messages","message_author","message_last_reply_date= " & ToHTML(fldmdate) & " and message_parent_id = " & ToHTML(fldmid) )
'*** bitti
SetVar "mcount", ToHTML(fldmcount)
SetVar "edit", fldedit
SetVar "member_id_author", ToHTML(fldmember_id_author)
SetVar "forum_id", ToHTML(fldforum_id)
Parse "DListDiscussions", True
'-------------------------------
' Discussions Show end
'-------------------------------
'-------------------------------
' Move to the next record and increase record counter
'-------------------------------
rs.MoveNext
iCounter = iCounter + 1
wend
'-------------------------------
'-------------------------------
' Discussions Navigation begin
'-------------------------------
bEof = rs.eof
if rs.eof and iPage = 1 then
SetVar "DiscussionsNavigator", ""
else
iCounter = 1
iHasPages = iPage
iDisplayPages = 0
iNumberOfPages = 20
while not rs.eof and iHasPages < iPage + iNumberOfPages
if iCounter = iRecordsPerPage then
iCounter = 0
iHasPages = iHasPages + 1
end if
iCounter = iCounter + 1
rs.movenext
wend
if rs.eof and iCounter > 1 then iHasPages = iHasPages + 1
if (iHasPages - iPage) < int(iNumberOfPages/2) then
iStartPage = iHasPages - iNumberOfPages
else
iStartPage = iPage - iNumberOfPages + int(iNumberOfPages/2)
end if
if iStartPage < 0 then iStartPage = 0
for iPageCount = iStartPage + 1 to iPage - 1
SetVar "NavigatorPageNumber", iPageCount
SetVar "NavigatorPageNumberView", iPageCount
Parse "DiscussionsNavigatorPages", true
iDisplayPages = iDisplayPages + 1
next
SetVar "NavigatorPageSwitch", "_"
SetVar "NavigatorPageNumber", iPage
SetVar "NavigatorPageNumberView", iPage
Parse "DiscussionsNavigatorPages", true
iDisplayPages = iDisplayPages + 1
SetVar "NavigatorPageSwitch", ""
iPageCount = iPage + 1
while iDisplayPages < iNumberOfPages and iStartPage + iDisplayPages < iHasPages
SetVar "NavigatorPageNumber", iPageCount
SetVar "NavigatorPageNumberView", iPageCount
Parse "DiscussionsNavigatorPages", true
iDisplayPages = iDisplayPages + 1
iPageCount = iPageCount + 1
wend
if bEof then
SetVar "DiscussionsNavigatorLastPage", "_"
else
SetVar "NextPage", (iPage + 1)
end if
if iPage = 1 then
SetVar "DiscussionsNavigatorFirstPage", "_"
else
SetVar "PrevPage", (iPage - 1)
end if
SetVar "DiscussionsCurrentPage", iPage
Parse "DiscussionsNavigator", False
end if
'-------------------------------
' Discussions Navigation end
'-------------------------------
'-------------------------------
' Finish form processing
'-------------------------------
set rs = nothing
SetVar "DiscussionsNoRecords", ""
Parse "FormDiscussions", False
'-------------------------------
' Discussions Close Event begin
' Discussions Close Event end
'-------------------------------
End Sub
'===============================
'===============================
' Display Search Form
'-------------------------------
Sub Search_Show()
Dim sFormTitle: sFormTitle = "FORUM"
Dim sActionFileName: sActionFileName = "Discussions.asp"
'-------------------------------
' Search Open Event begin
' Search Open Event end
'-------------------------------
SetVar "FormTitle", sFormTitle
SetVar "ActionPage", sActionFileName
'-------------------------------
' Set variables with search parameters
'-------------------------------
flds_topic = GetParam("s_topic")
'-------------------------------
' Search Show begin
'-------------------------------
'-------------------------------
' Search Show Event begin
' Search Show Event end
'-------------------------------
SetVar "s_topic", ToHTML(flds_topic)
'-------------------------------
' Search Show end
'-------------------------------
'-------------------------------
' Search Close Event begin
' Search Close Event end
'-------------------------------
Parse "FormSearch", False
End Sub
'===============================
%>