When programming in OScript, you may want to know if the current user is a Co-Ordinator of a project, this is signified by the user having delete permissions on the project. The code for this function is as follows :
function Boolean isUserCoOrdinator(Integer nodeID)
Object prgCtx = .prgSession() // get program context
CAPICONNECT connect = prgCtx.fDBConnect.fConnection // get DB Connection
Dynamic ProjectNode = DAPI.GetNodeById(connect, DAPI.BY_DATAID, nodeID) // get the Node
Boolean isCoOrd = False // Boolean indicating if the user has delete perms on the node
// if there was not an error creating the Node
if (!IsError(ProjectNode))
// does the user had Delete Permissions on this Node
isCoOrd = $LLIAPI.NodeUtil.CheckPermissions(ProjectNode, { $PDelete } )
end
return isCoOrd
end
The following code snippet shows how you could use this function to test if the the currently logged in user is a Co-Ordinator of the project with DTREE NodeID of 1234 :
if (.isUserCoOrdinator(1234))
echo("User is Co-Ordinator")
else
echo("User is NOT Co-Ordinator")
end