Search code examples
permissionshideliferayownerliferay-6

Liferay 6.0.5 - hide IGFolders from owner on private/public layout of his private community


We need to create hidden "system" subfolders in every IGFolder an normal user creates. The image gallery portlet resides mainly on the private community layouts of all normal users. The portlets and their configuration is pregenerated so the normal users can't change them (layout.user.[public|private].layouts.modifiable=false).

Why we want to do this In those system folders we'll store automatically generated size versions of the uploaded images. This is because we also import WebContent/JournalArticle representing image galleries which provide different sizes of the images themselves. In the end we want to display both the IGFolders and the JournalArticle content the same way without to much special code.

What i have tried already

  • I tried to do this via permissions (resource-actions/imgallery.xml => owner-defaults) but on his own community pages the user is also CommunityAdmin which gives him the rights to do & see almost whatever he wants. (PermissionCheckerBagImpl.isCommunityAdminImpl)

  • I thought of creating the layouts that don't belong to the user/his private Community, but testing this on a public page of another community that the users belongs to didn't work. I can't get the system to display the IGFolders of the current user at all, instead the folders of the community are displayed.

  • Using another user and group for the subfolders didn't work either, if the groupId does not match the one of the parent folder the parent folder id is set to 0, so they are longer subfolders at all (IGFolderLocalServiceImpl.getParentFolderId).

What might work and i probably just don't get right

  • changing the owner of the image gallery portlet/the layout

  • fiddling with the permission in a way i haven't thought of

  • adding another layer of groups/communities

  • putting the system folders somewhere else (which of course leads
    to more code for maintaining the relation between them and their
    parent folder)

Of course i could use expandos to flag the system folders - which i have to do anyway - and hide them after retrieval in the view but then i also would have to fiddle with the folder count, which i would like not to, since i feel this is not the way to do things.

Any ideas are appreciated, please don't feel shy to elaborate, I'm quite new to Liferay


Solution

  • You could create hook plugin and override in it (probably this file)

    /portal/portal-web/docroot/html/portlet/image_gallery/view_folders.jsp

    There you could add code to ignore your "system" folder if it exists. Perhaps all "system" folders could have same name (for example "_SYSTEM_FOLDER_") that you can test against.

    Take note that this just hides folders, so if someone knows folderId and has permission to see/edit it they could craft URL to access it.