Hi Appnair,
I am 100% agree with your views on permission level in livelnk. Actually what i want is to fix this below scenario:
I have one own created livelink item..lets say Forum, inside forum i have another item..lets say forumZone, now in this forumZone i have created 3 logical roles, i.e Host, participant and guest. Please note that these roles are not physical groups in livelink unlike default group, in another word these are not livelink objects. These roles fields are created under forumZone for only forum members to discuss the forum. Now the main point, inside forumzone i have a one link or feature to add livelink users and include them in one of the logical ROLES. Now inside forumZone i can add different livelink items also..lets say Agenda, Documents, URL, Notes, Now each Role have options to ADD, EDIT and DELETE checkboxes for each livelink items inside forumzone. Now this is the actual case and fucntionality of the forumzone module.
Now big one, when Admin added a USERA inside forumzone, Admin have to assign a role to USERA, lets say Admin have assign him Guest. Now there is another link which opens RolePrivilege page which shows all the permission checkboxes for each roles. So now admin is giving the logical permisions to each roles. Admin have given permission to GUEST role, that Guest can only ADD the agenda item but can not EDIT and DELETE the agenda item. Now since USERA is from Default group, and default group has the permissions of only SEE and SEE contents.
So when USERA logged in and when he gone inside forumzone, and then he went inside agenda item , so when USERA browsed the agenda item, the ADD button should come, but its not coming because i think USERA is inheriting the permissions from default group which only having SEE and SEEcontents permission.
So my question is how can we modify or update the permission of Agenda item such that when USERA will logged in, instead of fetching his permision from parent lets say default group, agenda item must show the permissions like EDIT or ADD or DELETE button depending upon the ROLES permission, the USERA belongs to.
I know its bit tricky, and also very confusing, but really a challenging issue. See here in my below code, when i open the Role privilege where i can set or assign the roles permission, this below function is calling which updates the roles permissions (NOT USER PERMISSION). Now here my problem is to set/update the user permissions in runtime, in the same time the ROLES permision are assigned for each livelink item, if only the user is in same ROLE.
THis application is purely in O Script: See below what i am doing to solve it,
Here is the function which calling another fucntion:
1. function void RolePrivileges2( \
Dynamic parm )
Assoc extendedData
Assoc result
Assoc rolePrivileges
Object prgCtx = parm.prgCtx
Dynamic request = parm.request
Dynamic response = parm.response
Assoc data = response.Data
Assoc err = parm.response.error
Boolean ok = TRUE
DAPINODE node = request.Node
Object dbConnect = prgCtx.fDbConnect
Object llnode = .LLNode() // My customization
echo(parm.request.node.Pname)
result = .LLNode().IsNodeEditable( prgCtx, node )
ok = ._IsNotError( prgCtx.fDBConnect, result, err )
if ok
result = llnode.RolePrivilegesGet( prgCtx, node )
ok = ._IsNotError( prgCtx.fDBConnect, result, err )
if ok
rolePrivileges = result.RolePrivileges
result = llnode.RolePrivilegesSetFromRequest( prgCtx, request, rolePrivileges, llnode) // My customization
ok = ._IsNotError( dbConnect, result, response )
if ok && result.Changed
extendedData = node.pExtendedData
extendedData.RolePrivileges = result.RolePrivileges
node.pExtendedData = extendedData
result = llnode.NodeUpdate( node )
ok = ._IsNotError( dbConnect, result, response )
end
end
end
// Redirect to the correct location.
if ok
result = ._SetLocation( prgCtx, request, response, .fOpenCmdName )
ok = ._IsNotError( dbConnect, result, err )
end
end
You can see above that its calling the function RolePrivilegesSetFromRequest(Note that i am passing llnode as 4th parameter in this function)
2.
function Assoc RolePrivilegesSetFromRequest( \
Object prgCtx, \
Dynamic request,\
Assoc rolePrivileges,\
Object llnode ) // My customization
Assoc moduleAssoc
Assoc roleAssoc
Assoc rtnval
Assoc aNewPerms
Assoc child
Dynamic apiError
Integer enabled
Integer role
Integer permission
Integer iCount // My customization
List modules
List privileges
List rolePermissionsList // My customization
List roles
String errMsg
String module
String privilege
String savedRolePrivileges
Boolean ok = TRUE
Boolean changed = FALSE
List childNodesList = DAPI.ListSubNodes(request.node); // My customization
savedRolePrivileges = Str.ValueToString( rolePrivileges )
modules = Assoc.Keys( rolePrivileges )
for module in modules
moduleAssoc = rolePrivileges.( module )
roles = Assoc.Keys( moduleAssoc )
for role in roles
roleAssoc = moduleAssoc.( role )
privileges = Assoc.Keys( roleAssoc )
for privilege in privileges
if ( Str.CmpI( privilege, "view" ) == 0 )
// Do nothing.
elseif ( Str.CmpI( module, "slideshowmodule" ) == 0 ) && ( Str.CmpI( privilege, "edit" ) == 0 )
// Do nothing.
else
enabled = ( IsFeature( request, Str.Format( '%1_%2_%3', module, role, privilege ) ) ) ? 1 : 0
if ( (rolePrivileges.( module ).( role ).( privilege ) = enabled) == 1 )
// My customization ------------
if ( privilege == "add" )
aNewPerms = Assoc.CreateAssoc()
aNewPerms.See = true
aNewPerms.SeeContent = true
aNewPerms.Create = true
Assoc permUpdateAssoc = Assoc.CreateAssoc()
permUpdateAssoc.Type = $LLIApi.UpdateRightReplace
permUpdateAssoc.PermType = DAPI.PERMTYPE_USER
permUpdateAssoc.RightId = request.node.pId
permUpdateAssoc.Permissions = $LLIAPI.NodeUtil.PermAssocToMask( aNewPerms )
rolePermissionsList = List.SetAdd(rolePermissionsList, permUpdateAssoc)
end
if ( privilege == "addnotes" )
aNewPerms = Assoc.CreateAssoc()
aNewPerms.See = true
aNewPerms.SeeContent = true
aNewPerms.Create = true
Assoc permUpdateAssoc = Assoc.CreateAssoc()
permUpdateAssoc.Type = $LLIApi.UpdateRightReplace
permUpdateAssoc.PermType = DAPI.PERMTYPE_USER
permUpdateAssoc.RightId = request.node.pId
permUpdateAssoc.Permissions = $LLIAPI.NodeUtil.PermAssocToMask( aNewPerms )
rolePermissionsList = List.SetAdd(rolePermissionsList, permUpdateAssoc)
end
if ( privilege == "edit" )
aNewPerms = Assoc.CreateAssoc()
aNewPerms.See = true
aNewPerms.SeeContent = true
aNewPerms.Modify = true
aNewPerms.EditAttr = true
Assoc permUpdateAssoc = Assoc.CreateAssoc()
permUpdateAssoc.Type = $LLIApi.UpdateRightReplace
permUpdateAssoc.PermType = DAPI.PERMTYPE_USER
permUpdateAssoc.RightId = request.node.pId
permUpdateAssoc.Permissions = $LLIAPI.NodeUtil.PermAssocToMask( aNewPerms )
rolePermissionsList=List.SetAdd(rolePermissionsList, permUpdateAssoc)
end
if ( privilege == "delete" )
aNewPerms = Assoc.CreateAssoc()
aNewPerms.See = true
aNewPerms.SeeContent = true
aNewPerms.DeleteVer = true
aNewPerms.Delete = true
Assoc permUpdateAssoc = Assoc.CreateAssoc()
permUpdateAssoc.Type = $LLIApi.UpdateRightReplace
permUpdateAssoc.PermType = DAPI.PERMTYPE_USER
permUpdateAssoc.RightId = request.node.pId
permUpdateAssoc.Permissions = $LLIAPI.NodeUtil.PermAssocToMask( aNewPerms )
rolePermissionsList = List.SetAdd(rolePermissionsList, permUpdateAssoc)
end
end
end
// My customization---------------------------------------
end
end
end
// My customization -------------------------
llnode.NodeRightsUpdate(request.node, rolePermissionsList);
if (childNodesList != 0)
for iCount = 1 to 5
llnode.NodeRightsUpdate(childNodesList[iCount], rolePermissionsList);
end
end
// My customization-----------------------
changed = Str.CmpI( Str.ValueToString( rolePrivileges ), savedRolePrivileges ) != 0
if IsUndefined( rtnval.OK )
rtnval.OK = ok
rtnval.ErrMsg = errMsg
rtnval.ApiError = apiError
rtnval.Changed = changed
rtnval.RolePrivileges = RolePrivileges
end
return rtnval
end
NOte that here it is calling NodeUpdateRights function (This fucntion is a parent function which can be overridden by sub items or sub nodes) which updates the permission i think so i am also calling this fucntion.
Now here everything is running but not able to achieve what i want. The permissions are not able to update.
Can you please look at my code, in which part i am giving wrong statment or guide me what shall i do?
Please also explain what is RIGHTID and PERMTYPE???
Cheers
smallredville