How to Create a Private Category

Title of Article

-->
A simple introductory example with a Category, its Downloads, and a menu item that can only be seen by specific users.
For Individual User Access see Single User Acess (opens in separate tab/window).

Here by a private category we mean that only people belonging to a specific Joomla User Group are able to see the category, and as a result only those people would be able to access any Download within that category. The reason why this is quite simple is because jDownloads fully implements the Joomla ACL scheme.

This example will outline what needs to be done to create a Private Category, or rather will show a way in which a Private Category may be implemented. There may well be other ways!

Much of the setup is within Joomla!.  We will have a user called Sam who will belong to a Joomla User Group called SamUG. We will also create a View Access called 'sam-view'. So first let us do the Joomla part.  The procedure does become a little more complex if there is also a need to allow Downloads to be created in the private category or in one of its subcategories from the frontend. To identify these sections then a Tahoma font and grey coloured text is used.


Setting up User Groups and view Access Levels
The first step is to create a new Joomla User Group. This is very simple, just go to User Groups and then use the create a new group button.

Give it the appropriate name, which in this case is SamUG and assign Registered as its Parent Group.

crepriv20
You may ask why use the Registered group as the 'base' group?  The reason is that if you give Edit or higher as the parent group then those users in the 'SamUG' group may be able to edit articles and other non jDownloads content.

If some of these Private Category users are also to be allowed to create or edit a Download in the Private category, then create another user group called say 'SamUploaderUG'. 
This User Group would have 'SamUG' group as its parent.  Members of the 'SamUploaderUG' will automatically become members of the 'SamUG' and the Registered user group by inheritance.
crepriv21

The result of creating the Sam-group with Registered as its parent group, and if appropriate the SamUploaderUG with SamUG as its parent, are shown opposite.

It is not the position in the list but the degree of indenting that indicates the ‘parent group’.

Once we have created the group we can assign users to it, and, most importantly, add the user group to a view Access Level.
crepriv23
The next step is to create a suitable view Access level so that only members of the SamUG will be able to see the Private Category.
So go to 'Users' - 'Access Levels' - 'Add New Access Level' and create an access level called SamView.
Add the SamUG as its only user group member.
If you have created a 'SamUploaderUG' then another view Access Level, called say SamUploaderView, will be required.  So repeat the process but with 'SamUploaderUG' as the only member.
crepriv22

Create Test Users
At this point it is probably useful to create some test users, one as a member of the SamUG and, if appropriate, another user as a member of the SamUploaderUG.  In my testing I called one Sam with an email of 'sam@nowhere.com' and the other as SamUploader with an email 'samuploader@nowhere.com'.   Sam was allocated to the SamUG user group and SamUploader was allocated to SamUploaderUG.

Menu Link to Create/Edit Downloads from Frontend

(This section is only required if you are allowing Downloads to be created in the 'private' category, sam-cat and any of its subcategories, from the frontend.)


Create a jDownloads menu in the usual way - for more information see [NEEDS REF] (opens in a new window/tab)

On the Details tab select menu item type as 'Create Download', and ensure you set view Access as SamUploaderView.


On the Options tab ensure you set 'Default Category' to No (this is the default setting). 

If you set to Yes then you will ONLY be able to set in that particular category and not any  of its subcategories.  See notes later on User Groups Settings.
crepriv26crepriv27crepriv27


The Joomla! parts are now done. So the next step is to create or modify a jDownload Category. In keeping with the rest of this example we will call the category ‘sam-cat'.


Create the jDownloads Category and Set Permissions


As shown opposite category ‘sam-cat’ is assigned to a suitable parent category, which in this example happens to be one called ‘Other’.

If required 'sam-cat' could be a top level category.  It could also have its own subcategories

The key step is of course to set the Access  to sam-cat and any of its subcategories to ‘sam-view’.

CrePriv05
(Section only required if creating/editing from front end)
After creating the category select the Permissions tab, then select the 'SamUploaderUG' user group.

Then as illustrated, in the 'Select New Setting' column choose Allowed for Create, Edit and Edit Own.  If you wish to allow the uploader to be able to change the Pubished state then also select the Edit State.  A green tickcrepriv tick will appear along side each permission as it is selected for modification.

Next click on the Save button crepriv save  in the tool bar.

The view will then show as opposite confirming that the permissions have been set and have propagated to all subcategories and their Downloads.
crepriv34crepriv35


Setting jDownloads User Group Ranking values and the Default Category
(This section is only required if you allow Downloads in the 'private' category to be created or edited in the frontend.)

So that the correct jDownloads User Groups settings apply then 'SamUploaderUG' must have a jDownloads ranking value larger that that of the Registered usergroup.

Please see [NEEDS REF] if you need more information about the importance of jDownloads ranking values.

To set the Ranking value go to Components and select jDownloads. 

Then select User Group Settings.

The Ranking entry is at the top of  the page just under the Group Title and before the tabs
A suitable value for the 'SamUploaderUG' would be say 121.
crepriv24

User Group Settings
(Section only required if creating/editing from front end)
We can use the User Groups Settings to specify what items the SamUploaderUG users can set when creating or modifying a Download in the private category, 'sam-cat'. 


There is one particular setting which is most important for our 'private' category in order to let it have private subcategories. This is in the 'Group Creation/Editing Settings'.  Make sure that the option 'May select a different Category is set to Yes as indicated opposite.

To demonstrate this a subcategory of 'sam-cat' called 'sub-private' was created.  When it was created then 'sub-private' automatically acquired the permissions and view access of its parent, 'sam-cat'. 
Similarly when Downloads are created they acquire the permissions and view access of their containing category.

So when creating a new Download from the front end, jDownloads will only show the appropriate categories for section.
crepriv36crepriv37
Front End View
We are now done, but let us see what happens from the front end.


First when user sam is not Logged in.

The Overview shows only one subcategory in category 'Other'.

Clicking on the title of subcategory Other shows that the only subcategory is one called 'normal-cat'.

CrePriv30crepriv31

Now when user sam is logged in.

The Overview now shows there are two subcategories in category 'Other'.

Clicking on 'Other' shows that there are now two subcategories, one called 'normal-cat' and the other one is our private category 'sam-cat'.

CrePriv32crepriv33
This can obviously be extended so that different groups have different 'Private Categories' and they have their own menu item for creating/editing Downloads from the frontend.  Some users could belong to multiple groups.
ACL and View management can be "challenging" at first.  Many tutorials concentrate on just the ACL permisions themselves but it is the combination of that with View Access that creates the flexibility.  For more extensive examples see 'Controlled Access to Categories and Downloads' [NEEDS REF]

ColinM November 2019

Print Email