Wednesday, June 27, 2007

Updating a manager in all rooms

Quickr was just released and it has a new concept of "super user" per place. For older versions, the best we could do is a manager in all rooms. This is a script that will add a manager in every room of a given place:

Set s = New notessession
placename = "placename"
server = "www/projectlounge"
aclname = "CN=Ian Connor/O=projectlounge"

Print "Starting in main room"
Call restoredb(placename, "quickplace/"+placename+"/main.nsf", aclname)

Sub restoredb(roomtitle, roompath, aclname)
Dim roomdb As NotesDatabase
Dim roomview As notesview
Dim doc As notesdocument

Set roomdb = s.GetDatabase(server, roompath)

If roomdb.IsOpen = False Then
Call roomdb.Open(server, roompath)
End If

Dim acl As NotesACL
Dim entry As NotesACLEntry
Set acl = roomdb.ACL
Set entry = acl.GetEntry( aclname )

If entry Is Nothing Then
Set entry = acl.CreateACLEntry _
( aclname, ACLLEVEL_MANAGER )
entry.IsPerson = True
Call entry.EnableRole( "h_Managers" )
Call entry.EnableRole( "h_Members" )
Call acl.Save
End If

Set roomview = roomdb.GetView("System\Subrooms")
Set doc = roomview.GetFirstDocument

While Not (doc Is Nothing)
Dim iroomtitle As String
Dim iroomfile As String

iroomtitle = doc.GetItemValue("h_Name")(0)
iroomfile = doc.GetItemValue("h_LocDbName")(0)

Print "Working on: " + iroomfile
Call restoredb(iroomtitle, "quickplace/"+placename+"/" + iroomfile, aclname)

Set doc = roomview.GetNextDocument(doc)
Wend
End Sub

0 Comments:

Post a Comment

<< Home