As always I'm tinkering around in my IDE. Today's challenge is to set up view level ACL rules for each of the various managers (list/form views) in my test management component.

First I added the required sections to the access.xml file

<?xml version="1.0" encoding="UTF-8"?>
<access component="com_babelu_exams">
<section name="component">
    <action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" />
    <action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" />
    <action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC" />
    <action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" />
    <action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" />
    <action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_COMPONENT_DESC" />
    <action name="core.edit.own" title="JACTION_EDITOWN" description="JACTION_EDITOWN_COMPONENT_DESC" />
<section name="category">
    <action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_CATEGORY_DESC" />
    <action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_CATEGORY_DESC" />
    <action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_CATEGORY_DESC" />
    <action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_CATEGORY_DESC" />
    <action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_CATEGORY_DESC" />
    <action name="core.edit.own" title="JACTION_EDITOWN" description="JACTION_EDITOWN_CATEGORY_DESC" />
<section name="level">
    <action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_LEVEL_DESC" />
    <action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_LEVEL_DESC" />
    <action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_LEVEL_DESC" />
    <action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_LEVEL_DESC" />
    <action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_LEVEL_DESC" />
    <action name="core.edit.own" title="JACTION_EDITOWN" description="JACTION_EDITOWN_LEVEL_DESC" />
<section name="exam">
    <action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_EXAM_DESC" />
    <action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_EXAM_DESC" />
    <action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_EXAM_DESC" />
    <action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_EXAM_DESC" />
    <action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_EXAM_DESC" />
    <action name="core.edit.own" title="JACTION_EDITOWN" description="JACTION_EDITOWN_EXAM_DESC" />
<section name="section">
    <action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_SECTION_DESC" />
    <action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_SECTION_DESC" />
    <action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_SECTION_DESC" />
    <action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_SECTION_DESC" />
    <action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_SECTION_DESC" />
    <action name="core.edit.own" title="JACTION_EDITOWN" description="JACTION_EDITOWN_SECTION_DESC" />
<section name="problem">
    <action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_PROBLEM_DESC" />
    <action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_PROBLEM_DESC" />
    <action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_PROBLEM_DESC" />
    <action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_PROBLEM_DESC" />
    <action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_PROBLEM_DESC" />
    <action name="core.edit.own" title="JACTION_EDITOWN" description="JACTION_EDITOWN_PROBLEM_DESC" />
<section name="result">
    <action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_RESULT_DESC" />
    <action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_RESULT_DESC" />
    <action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_RESULT_DESC" />
    <action name="core.edit.own" title="JACTION_EDITOWN" description="JACTION_EDITOWN_RESULT_DESC" />

Then I tried to add these to my config.xml under the permissions fieldset

<fieldset name="permissions" description="JCONFIG_PERMISSIONS_DESC"
    <field name="rules" type="rules" component="com_babelu_exams"
        filter="rules" validate="rules" label="JCONFIG_PERMISSIONS_LABEL"
        section="component" />

    <field name="rules" type="rules" component="com_babelu_exams"
           filter="rules" validate="rules" label="JCONFIG_PERMISSIONS_LABEL"
           section="category" />

However this didn't work as the category rules overwrote the component rules. So I tried making rules an array

<fieldset name="permissions" description="JCONFIG_PERMISSIONS_DESC"
    <field name="rules[]" type="rules" component="com_babelu_exams"
        filter="rules" validate="rules" label="JCONFIG_PERMISSIONS_LABEL"
        section="component" />

    <field name="rules[]" type="rules" component="com_babelu_exams"
           filter="rules" validate="rules" label="JCONFIG_PERMISSIONS_LABEL"
           section="category" />

but this had the same effect. So I tried appending the section to the component attribute, but this just caused the entire permissions control to go blank.

So does anyone know if what I am trying to do is possible within the com_config component view?

The reason I want to have this at the component level is because I'm trying to achieve full cascading ACL. Where in the super admin can set ACL to the component-> the view-> the record. Which will allow me to hid sections of the component that are not relative to the current users access permissions.

So if you know how this could be done using com_config please let me know. =^D I'll be searching for a solution in the mean time, if I find it I'll post.

Happy Joomla!ng


Not sure if it's a typo but the access.xml is missing the closing </access> tag.

I never tried but I don't think you can have multiple permissions fields in the same config.

  • The component section is used on the component level options.
  • The category one is used by com_categories for the single category permissions.
  • The others may be used for single item permissions. Like in case of com_content you have an article section which is used to set the permissions for each article individually.

If you need separate ACL for each views, you need to create own ACL rules and don't use the core ones. Like com_babelu_exams.level.create.

  • Ya the closing access was a copy/paste error. It is in the actual access.xml Jun 13 '14 at 2:17
  • As for your answer, I really appreciate the time you took to write it all out. But that method is what I'm moving away from. I currently have it set up with component level ACL actions like core.manage.level which works, but it still doesn't allow me to control each view with the precision I want without creating an unrealistic number of custom actions. Plus it won't cascade which is the biggest selling point of the ACL system. Jun 13 '14 at 2:23
  • I just wrote how it works currently. The section refer to the "vertical" level, eg "Component" -> "Category" -> "Item". You're trying to use it for the "horizontal" level, eg different type of views/items. That's not going to work with sections, but would work with different action names. Obviously it doesn't play well with your single task controllers. You may want to get in contact with Sander if you want to change the ACL system.
    – Bakual
    Jun 13 '14 at 12:33
  • Actually I got it working. I'm still testing, but for the most part it is cascading nicely. You were correct that I couldn't have multiple rules in the config, that is unfortunate, but I was able to add the rule field to the list form and create a simple controller to handle saving it. Since my models already append the subject to the asset name, I pass com_babelu_exams and the model sends com_babelu_exams.subject to user->authorise. I still need to re-factor and test a little bit, but I'm happy with the result. I'll post once I'm finished. Jun 13 '14 at 12:45
  • I'm accepting your answer, because indeed you cannot achieve this with the com_config component. Jun 13 '14 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.