%@LANGUAGE="VBSCRIPT"%>
<%
Option explicit
Response.Expires = 0 ' always load the page, dont store
%>
<%
'=====================================================
' _wform_change_licence.asp
'
' This form is designed to work within an iframe pop up
'=====================================================
%>
<%
'------------ ACCESS CONTROL ------------------
%>
<%
'------------ Variable Definition -------------
Dim parPv_id
Dim sMessage, sMessageType
'------------ Constants Declaration -----------
'------------ Variable Init -------------------
Set pkgInfoHash = CreateObject("Scripting.Dictionary")
parPv_id = QStrPar("pv_id")
sMessage = NULL
sMessageType = 3
'----------------------------------------------
%>
<%
'------------------------------------------------------------------------------------------------------------------------------------------
'
' Add a line of text to the System Message
' eLevel - 1 == Critical, 2==Warning, 3==Note
Sub sMessageAdd(eLevel, text)
If NOT isNull(sMessage) Then
sMessage = sMessage & "
"
End If
sMessage = sMessage & text
If eLevel < sMessageType Then
sMessageType = eLevel
End If
End Sub
Sub Get_Pkg_Info_With_Licence ( NNpv_id )
Dim rsTemp, Query_String
Query_String = _
" SELECT pkg.pkg_name, pv.pkg_version, NVL(ld.licence, -2) as licence_id"&_
" FROM packages pkg, package_versions pv, licencing ld"&_
" WHERE pkg.pkg_id = pv.pkg_id"&_
" AND pv.pv_id = " & NNpv_id &_
" AND ld.pv_id(+) = pv.pv_id"
Set rsTemp = OraDatabase.DbCreateDynaset( Query_String, cint(0))
If ((NOT rsTemp.BOF) AND (NOT rsTemp.EOF)) Then
pkgInfoHash.Add "pkg_name", (rsTemp.Fields("pkg_name"))
pkgInfoHash.Add "pkg_version", (rsTemp.Fields("pkg_version"))
pkgInfoHash.Add "licence_id", (rsTemp.Fields("licence_id"))
End If
rsTemp.Close
Set rsTemp = nothing
End Sub
Function Licence_List ( )
Licence_List = _
" SELECT l.licence as licence_id, l.name"&_
" FROM licences l "&_
" ORDER BY UPPER(l.name)"
End Function
Function Update_Licence ( NNpv_id, NNlicence_id )
Dim rsTemp, Query_String, sComments
Dim licenceText
Update_Licence = FALSE
If CInt(NNlicence_id) < 0 Then
Update_Licence = TRUE
Exit Function
End If
' Check for a change
If CInt(NNlicence_id) = CInt(pkgInfoHash.Item("licence_id")) Then
Update_Licence = TRUE
Exit Function
End If
'-- Get licence details. Next text name for logging
Query_String = _
" SELECT licence, name"&_
" FROM licences"&_
" WHERE licence = "& NNlicence_id
Set rsTemp = OraDatabase.CreateDynaset( Query_String, cint(0))
licenceText = rsTemp.Fields("name").Value
If isNUll(licenceText) OR licenceText = "" Then
sMessageAdd 1, "Licence text cannot be found"
Exit Function
End If
rsTemp.Close
Set rsTemp = nothing
Query_String = _
"MERGE INTO LICENCING ld" &_
" USING (SELECT "& NNpv_id & " pv_id, "& NNlicence_id & " licence from dual) s" &_
" ON (ld.pv_id = s.pv_id)" &_
" WHEN MATCHED THEN UPDATE SET ld.licence = s.licence" &_
" WHEN NOT MATCHED THEN INSERT (pv_id, licence) VALUES (s.pv_id, s.licence)"
sComments = "Set: " & licenceText
'-- Update database to change the owner
objEH.ErrorRedirect = FALSE
objEH.TryORA ( OraSession )
On Error Resume Next
' Update the licence
OraDatabase.ExecuteSQL Query_String
objEH.CatchORA ( OraSession )
If objEH.LastOraFailed = FALSE Then
'-- Log the change
Call Log_Action ( NNpv_id, "software_licence", sComments )
Update_Licence = TRUE
End If
End Function
Function Delete_Licence ( NNpv_id )
Dim rsTemp, Query_String, sComments
Delete_Licence = FALSE
' Delete any exsiting licence
' Check for a change
If CInt(pkgInfoHash.Item("licence_id")) < 0 Then
Delete_Licence = TRUE
Exit Function
End If
'-- Update database to change the owner
objEH.ErrorRedirect = FALSE
objEH.TryORA ( OraSession )
On Error Resume Next
' Update the licence
OraDatabase.ExecuteSQL _
" DELETE from LICENCING ld "&_
" WHERE ld.pv_id = "& NNpv_id
objEH.CatchORA ( OraSession )
If objEH.LastOraFailed = FALSE Then
'-- Log the change
Call Log_Action ( NNpv_id, "software_licence", "Deleted Licence" )
Delete_Licence = TRUE
End If
End Function
%>
<%
Call Get_Pkg_Info_With_Licence ( parPv_id )
'Process submition
If CBool(QStrPar("action")) AND objAccessControl.UserLogedIn Then
If Request("btn") = "Delete" Then
If Delete_Licence (parPv_id) Then
Call ReloadParentWindow
Call CloseWindow
End If
Else
If Update_Licence ( parPv_id, Request("licence_id") ) Then
Call ReloadParentWindow
Call CloseWindow
End If
End If
End If
%>
<%
If objAccessControl.UserId = "" Then
sMessageAdd 1, "No longer logged in"
End If
%>