by
KK » Tue Jan 13, 2015 12:04 am
Hi cardmaverick,
I'm glad you devised an alternative solution.
However, as appears from your subsequent post (
viewtopic.php?f=2&t=8844), since this has some hitches let us persist with your original solution in this thread (i.e. extended-folders in relation with extended-users).
I've worked out a way to enforce the kind of access-control you desired.
Please try the following out and let me know it works for you.
Create a file named 'check_access.html' and place it in your 'couch/snippets' folder.
Put the following code within it -
- Code: Select all
<cms:set my_has_access='0' 'global' />
<cms:if k_logged_in >
<cms:pages masterpage=k_template_folder_masterpage page_name="folder-<cms:show my_folder_id />">
<cms:related_pages 'display_name' page_name=k_user_name>
<cms:set my_has_access='1' 'global' />
</cms:related_pages>
</cms:pages>
</cms:if>
As I mentioned in an earlier post, we'll have to check access in all the different views.
Let us try it in the page-view first. Put the following in your 'proof-gallery.php' -
- Code: Select all
<cms:if k_is_page>
<cms:embed 'check_access.html' my_folder_id=k_page_folderid />
<cms:if my_has_access >
<!-- html page code here -->
<cms:show k_page_title />
<cms:else />
<h2>Access denied!<h2>
</cms:if>
</cms:if>
Basically we are are invoking our 'check_access.html' snippet with the folder id of the current page. The snippet works through the two related templates and sets 'my_has_access' variable to '1' if the currently logged-in user has been given access.
If the above works, we can use the following in the folder-view -
- Code: Select all
<cms:if k_is_folder>
<cms:embed 'check_access.html' my_folder_id=k_folder_id />
<cms:if my_has_access >
<a href="<cms:show k_folder_link />"><cms:show k_folder_title /></a><br />
<cms:else />
<h2>Access denied!<h2>
</cms:if>
</cms:if>
The logic remains the same - just notice that the variable containing the folder id is different in folder-view (compared to page-view).
Finally the view where we list the folders (the requirement being that we should only show those folders that the current user has access to) -
- Code: Select all
<cms:folders >
<cms:embed 'check_access.html' my_folder_id=k_folder_id />
<cms:if my_has_access >
<a href="<cms:show k_folder_link />"><cms:show k_folder_title /></a><br />
</cms:if>
</cms:folders>
Hope this helps.
Please let us know.