%@ language=VBScript %>
<%
' ///////////////////////////////////////////////////////
' // Dimac CMS
' // Copyright 2004-2008 Dimac Development AB, Sweden
' // www.Dimac.net
' //
' // NOTE:
' // You are not allowed to remove this
' // Copyright information without written
' // permission from Dimac Development.
' ///////////////////////////////////////////////////////
If NOT CBool(Session("ValidAdminUser")) Then
Response.Redirect("../LIO/loggin.asp")
End IF
Dim intDocStatus : intDocStatus = 0
Dim vTrashBinID : vTrashBinID = GetSettingValue("TrashBinID", "..\..\SiteResources\Data\")
' -------------------------------------------------------
' -- get owner ID for a document
' -------------------------------------------------------
Function GetDocOwnerID(vDoc)
Dim Conn, Rs1, StrSql
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs1 = Server.CreateObject("ADODB.Recordset")
Conn.Open GetConStr ("..\..\SiteResources\Data\")
StrSql = "SELECT CreatedBy FROM Documents WHERE DocumentID = " & vDoc
Rs1.Open StrSql , Conn
If not Rs1.EOF Then
GetDocOwnerID = Rs1("CreatedBy").value
Else
GetDocOwnerID = 0
End IF
rs1.Close
Set Rs1 = Nothing
Set Conn = Nothing
End Function
' -------------------------------------------------------
' -- Get user name
' -------------------------------------------------------
Function GetDocOwnerName(vDoc)
Dim Conn, Rs1, StrSql
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs1 = Server.CreateObject("ADODB.Recordset")
Conn.Open GetConStr ("..\..\SiteResources\Data\")
StrSql = "SELECT FirstName, LastName FROM Users WHERE UserID = " & vDoc
Rs1.Open StrSql , Conn
If not Rs1.EOF Then
GetDocOwnerName = Rs1("FirstName").value & " " & Rs1("LastName").value
Else
GetDocOwnerName = " "
End IF
rs1.Close
Set Rs1 = Nothing
Set Conn = Nothing
End Function
' -------------------------------------------------------
' -- Check if the Document already is in the TrashBin
' -------------------------------------------------------
Function IsInTrash(vDoc, vTrashBinID)
Dim Conn, Rs1, StrSql
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs1 = Server.CreateObject("ADODB.Recordset")
Conn.Open GetConStr ("..\..\SiteResources\Data\")
StrSql = "SELECT ParentID FROM Documents WHERE DocumentID = " & vDoc
Rs1.Open StrSql , Conn
IsInTrash = FALSE
If not Rs1.EOF Then
If CStr(Rs1(0).Value) = vTrashBinID Then
IsInTrash = TRUE
End If
End IF
rs1.Close
Set Rs1 = Nothing
Set Conn = Nothing
End Function
' -------------------------------------------------------
' -- Move document to the TrashBin
' -------------------------------------------------------
Function MoveToTrashBin(vDoc, vTrashBinID)
Dim Conn, Rs1, StrSql
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs1 = Server.CreateObject("ADODB.Recordset")
Conn.Open GetConStr ("..\..\SiteResources\Data\")
MoveToTrashBin = FALSE
If IsNumeric(vTrashBinID) And vTrashBinID > 0 Then
StrSql = "UPDATE Documents SET prevParentID=ParentID, ParentID = " & vTrashBinID & " WHERE DocumentID = " & vDoc
Conn.Execute( StrSql )
MoveToTrashBin = TRUE
intDocStatus = 2
End If
Set Conn = Nothing
End Function
' -----------------------------------------------------
' // Security Check
' -----------------------------------------------------
vDocOwnerID = GetDocOwnerID(Session("DocID"))
IF NOT CheckSecurity(Session("DocID"), Session("User_Group") , "DELETE" , "..\..\" , vDocOwnerID ) THEN
Response.Write("")
Response.write("
")
Response.Write(langErrorSecurityAccess)
Response.write("
")
Response.write( lagLabelSecDelete & " " & Session("DocID"))
Response.write("
")
Response.Write(langLabelCreatedBy & " " & GetDocOwnerName(vDocOwnerID) )
Response.Write("")
Response.End
END IF
' -----------------------------------------------------
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
Conn.Open GetConStr ("..\..\SiteResources\Data\")
' -------------------------------------------------------
Sub Delete( nID )
SQL = "SELECT ParentID FROM Documents WHERE DocumentID = " & nID
set Rs = Conn.Execute(SQL)
If Rs("ParentID").value >= 0 Then
SQL = "DELETE FROM Documents WHERE DocumentID = " & Session("DocID")
set Rs = Conn.Execute(SQL)
SQL = "DELETE FROM DocumentFields WHERE DocID = " & Session("DocID")
set Rs = Conn.Execute(SQL)
SQL = "DELETE FROM DocumentLanguages WHERE DocID = " & Session("DocID")
set Rs = Conn.Execute(SQL)
intDocStatus = 1
Else
intDocStatus = 0
Response.write("
")
Response.write("