In this tutorial I’m going to show you how to write your own XML component description files for Mighty Permission Component. The main purpose of the XML file here is to specify the set of actions for desired component that you are going to set permissions for.
Before I start to explain you how to create XML file let me explain how Mighty Permission works in general. If you understand that, then you do not need to understand what is XML file for and how to manage but simple to learn XML syntax.
First you need to understand Mighty Permision URL based ACL. What does that mean? Let me show an example. Say, you have URL http://yoursite.com/index.php?option=com_content&view=article&task=add_comment&... This URL submits comment to the article. Mighty Permission can say Joomla “Please, do not allow this user or user group to access any URL where task = add_comment in com_content component”.
But for Mighty Permission to tell Joomla this, it must know that this variation exists. That is what XML files stand for. For example, to help JS Permission to know that we want to manage variation I described above, simple add to XML line
<variable task=”add_comment”>Add Comment</variable>
That is it. And even more. Imagine you want to restrict only adding comments to article ID 123. Then create line
<variable task=”add_comment” article=”123”>
Add Comment to my favorite article</variable>
Another example on managing publish ability.
<variable task=”publish”> Publish</variable>
This is general publish task. But what if our component has 2 sections like say category manager and item manager and task=publish in both section but you want manage publish ability in every section separately?
<variable task=”publish” controller=”category”> Publish category</variable>
<variable task=”publish” controller=”item”> Publish Item</variable>
Just look into URL and you will intuitively understand what you need to add.
You will ask, where is the component option? Every Joomla URL or post request has option parameter. And value of this parameter is a name of the component that will handle this URL.
You do not need to set component option in XML. You will create different XML for each component and set component name in <component> tag like this <component option='com_example'>
So here is the flow. When any Joomla page is requested, Mighty Permission plugin detect what component will handle this URL, then JS Permission plugin look through all XML files on your site and if do not find just allows to go through and if find it look inside all URL variations listed and if match anything see if this user can do that or not and as a result return user on previous page or grand an access.
Ok, now let me show you whole file and explain you more details.
<?xml version="1.0" encoding="utf-8"?>
<component option='com_categories'>
<name>Joomla Categories</name>
<author>joomSuite</author>
<version>1.0</version>
<email>support@mightyextensions.com</email>
<site>http://www.joomosuite.com</site>
<license>Comemrcial</license>
<copyright>JoomSuite</copyright>
<description>This XML Document is made to
manage permissions for Joomla Categories</description>
<group name='Weblinks Categories Management'>
<variable section='com_weblinks' task='add'>Add a Category</variable>
<variable section='com_weblinks' task='remove'>Remove a Category</variable>
<variable section='com_weblinks' task='edit'>Edit a Category</variable>
<variable section='com_weblinks'
task='publish'>Publish a Category(ies)</variable>
<variable section='com_weblinks'
task='unpublish'>Unpublish a Category(ies)</variable>
</group>
<group name='Contacts Categories Management'>
<variable section='com_contact' task='add'>Add a Category</variable>
<variable section='com_contact' task='remove'>Remove a Category</variable>
<variable section='com_contact' task='edit'>Edit a Category</variable>
<variable section='com_contact'
task='publish'>Publish a Category(ies)</variable>
<variable section='com_contact'
task='unpublish'>Unpublish a Category(ies)</variable>
</group>
</component>
I deleted some groups from it because it is too long. You XML should always start with <?xml version="1.0" encoding="utf-8"?>.
All other XML tags should be inside <component> tag and <component> tag should have option attribute that is equal to component name.
<name>Example</name> - is the name of your configuration. Not necessary it to be equal to component name.
<author>John Doe</author> - the name of the author (your name)
<version>1.0</version> - XML version
<email>krik123@bk.ru</email> - author email in case to ask questions
<site>http://www.joomlaequipment.com</site> - Author website may be to look for updates
<license>Freeware</license> - License type
<copyright>JoomSuite</copyright> - Copyright
<description>This XML Document is made to manage permissions for Articles</description> - description means description
By using <group> and </group> tags you can divide all action according to groups for your comfort, for example you have a component with many section like Virtuemart. You can group your actions like this
- Products
- Add new
- Publish
- Unpublish
- Delete
- Edit
- Add price
- Categories
- Add new
- Publish
- Unpublish
- Delete
- Edit
- Orders
- Add new
- Publish
- Unpublish
- Delete
- Edit
- Shipping
Then on set permission page it will be easier to find required action. But it is optional and you can just write one group and write all the actions in one group.
So, now I hope you’ll be able to write your own XML files for JS Permission component.
Thanks for your attention and have a good day.