[Issue] Close form by macro - access protection of forms
Posted: Sun Jul 13, 2008 9:41 am
I want to implement some kind of simple access control on my forms. I have a form which I only want myself to be able to access. When loading the form I check for the OS-username. If the function returns false the form closes. This works well. However, on second attempt to open the document the macro's don't get called on startup. After manually closing and reopening the form the startup macro's do work, fourth they don't etc.
I suppose this is an error in OOO2.4.1, I've run into somthing similar before. Does anyone have an idea how to accomplish the permissions system per form? Of course, I could just offer the forms and set the permissions on my mysql-database per table (I should do that anyway to prevent other users from reading the data through the tables) but I also want to protect the forms.
Code: Select all
Sub onloadpersoneelsdossier
if checkpermissionspersoneelsdossier = "false" then
'thisComponent.CurrentController.Frame.close( true )
thisComponent.CurrentController.Frame.dispose()
exit sub
end if
end Sub
function checkpermissionspersoneelsdossier as string
Dim oForm, oCtrl, oState, oCtrl2, oField, naam
oForm=ThisComponent.Drawpage.Forms.getByName("MainForm")
If GetGuiType = 1 Then
naam = Environ( "USERNAME" ) ' Windows
ElseIf GetGuiType = 4 Then
naam = Environ( "USER" ) ' Unix, Linux
Else
MsgBox "Unknown operating system!", 16
' Mac OS => GetGuiType = 3
End If
msgbox("sluiten")
'if naam<>"Bas" then
checkpermissionspersoneelsdossier="false"
'end if
end function