Juergen
What are the pieces of information you have available to you? I am going to assume the very minimum, parentID and the userID correct?
Regards
David Templeton
OpenText Corporation
From: eLink Entry: Content Server Builder Forum [mailto:componentbuilder@elinkkc.opentext.com]Sent: Friday, March 02, 2012 8:16 AMTo: eLink RecipientSubject: list folder content within user context
list folder content within user context
Posted byjuergen.riemer@osce.org (Riemer, Juergen) On 03-02-2012 08:09
Hi,
I'd need to get the content of a folder within a users context, i.e. list all elements that a particular user is allowed to see.
Any ideas how I could do that with OScript?
Thanks,
[To post a comment, use the normal reply function]
Forum:
Content Server Builder Forum
Content Server:
Knowledge Center
Hi Dave,
exactly, id of folder node and id of user.
Once you have the session of the user, which you need to do anything :-) Look at the attached source.
Wow that was quick! Thanks a lot!
I will have a look at the code immediately.
Hi David, Thanks again for your code snippet. It works like a charm. The reason for my request was that I want to create a menu structure (HTML unordered list) out of a DocIn folder structure which is nice because we can fall back on Content Server's ACL to control menu items. Below is the code I came up with and plan to put into a web lingo file. Works nice! Just one last question, do you think we run into any performance issue haveing to query for each subfolder? Is there a possibility to recursively query nodeListContents, if so, would you recommend doing so? ---8<--- <ul> ; Assoc checkVal ; Assoc aQuery ; Assoc rtnVal ; Dynamic apiError ; Object llNode ; Object parentNode ; RecArray contents ; RecArray lrResources ; Boolean ok = TRUE ; Record rResource ; Integer nidMenu =23765193 ; Object dapiCtx = .fPrgCtx.DSession() ; parentNode = DAPI.GetNodeByID( dapiCtx.fSession, DAPI.BY_DATAID, nidMenu, False ) ; if ( IsDefined( parentNode ) && IsNotError( parentNode )) ; llnode = $LLIAPI.LLNodeSubsystem.GetItem( parentNode.pSubType ) ; checkVal = llNode.NodeListContents( parentNode, "WebNodes" ) ; if ( checkVal.ok ) ; contents = checkVal.contents ; for rec in contents ; if( rec.subType == 0 ) <li>`rec.name`</li> ; parentNode = DAPI.GetNodeByID(dapiCtx.fSession, DAPI.BY_DATAID, rec.dataid, False ) ; llnode = $LLIAPI.LLNodeSubsystem.GetItem( parentNode.pSubType ) ; checkVal = llNode.NodeListContents( parentNode, "WebNodes" ) ; if( checkVal.ok ) ; lrResources = checkVal.contents <ul> ; for rResource in lrResources ; if( rResource.subType == 140 ) <li><a href="`rResource.exatt1`">`rResource.name`</a></li> ; end ; end </ul> ; end ; ; end ; end ; else ; // log error ; end ; else ; // log error ; end </ul>
To use a phrase, “been there done that and have the t-shirt”J no I wouldn’t instead I would get any sub folders etc from a json/ajax combination, in fact I would make the first menu populate on first hit not on the original page drawing, therefore if the user doesn’t need the menu then you won’t be incurring the performance issue.
That being said, as you can imagine ideally the best way would be to export some kind of XML file of the information and the make at least the top level public perms.
David
From: eLink Entry: Content Server Builder Forum [mailto:componentbuilder@elinkkc.opentext.com]Sent: Monday, March 05, 2012 8:27 AMTo: eLink RecipientSubject: list folder content within user context
Posted byjuergen.riemer@osce.org (Riemer, Juergen) On 03-05-2012 08:21
Hi David,Thanks again for your code snippet. It works like a charm.The reason for my request was that I want to create a menu structure (HTML unordered list) out of a DocIn folder structure which is nice because we can fall back on Content Server's ACL to control menu items.Below is the code I came up with and plan to put into a web lingo file. Works nice!Just one last question, do you think we run into any performance issue haveing to query for each subfolder? Is there a possibility to recursively query nodeListContents, if so, would you recommend doing so?---8<---<ul>; Assoc checkVal; Assoc aQuery; Assoc rtnVal; Dynamic apiError; Object llNode; Object parentNode; RecArray contents; RecArray lrResources; Boolean ok = TRUE; Record rResource; Integer nidMenu =23765193; Object dapiCtx = .fPrgCtx.DSession(); parentNode = DAPI.GetNodeByID( dapiCtx.fSession, DAPI.BY_DATAID, nidMenu, False ); if ( IsDefined( parentNode ) && IsNotError( parentNode )); llnode = $LLIAPI.LLNodeSubsystem.GetItem( parentNode.pSubType ); checkVal = llNode.NodeListContents( parentNode, "WebNodes" ); if ( checkVal.ok ); contents = checkVal.contents; for rec in contents; if( rec.subType == 0 ) <li>`rec.name`</li>; parentNode = DAPI.GetNodeByID(dapiCtx.fSession, DAPI.BY_DATAID, rec.dataid, False ); llnode = $LLIAPI.LLNodeSubsystem.GetItem( parentNode.pSubType ); &nbs! p; checkVal = llNode.NodeListContents( parentNode, "WebNodes" ); if( checkVal.ok ); lrResources = checkVal.contents <ul>; for rResource in lrResources; if( rResource.subType == 140 ) &n! bsp; <li><a href="`rResource.exatt1`">`rResource.name`</a></li>; end; end </ul>; end; ; end; end; else; ! // log error ; end; else; // log error ; end</ul>
Topic:
To use a phrase, “been there done that and have the t-shirt” J no I wouldn’t instead I would get any sub folders etc from a json/ajax combination, in fact I would make the first menu populate on first hit not on the original page drawing, therefore if the user doesn’t need the menu then you won’t be incurring the performance issue.
Hi David, That's an interesting take indeed. That means we could also use solely Appearances, the main menu structure being hard coded HTML, the restricted sub menu items could be queried by simple <ot:OTmacro_listItems> item inside the Appearance and populate the restricted menu structure via JavaScript. Thanks for the input and expert's opinion! Juergen