One of the most common problems that developers face when finishing a project based on Joomla is user access management, or to be more exact, the lack of user access control! There are numerous solutions on this issue like the commercial component from Joomla Solutions which is called JBAM (Joomla backend access management - $125) and the free component JACLPlus from Byostech. Both are hacks to the core files of Joomla and each has its drawbacks, so many users/developers may be a little sceptical on using them.
Don't get me wrong! But JACL is version dependant and JBAM is way to complicated (and pricey) when all you want to do is give your managers access to the Polls component!!!
So what other options do we have? Well, hack one file a bit and give any user group access to any component yourself!The file is includes/gacl.class.php.We can easily assign access to certain components for certain groups. E.g. you might want to give your website Administrator the rights to add/delete user accounts on the backend, but not access to modules or mambots! Or you might want to give Managers access to a third-party component like ArtBanners (for ad banner management) which seems quite logical if you deal with lot of content and want to distribute different tasks to different people.
So we simply change or add a few lines in includes/gacl.class.php and we can totally control what parts of the site the 3 predefined backend management user groups (Super Admin, Admin, Manager) can access!
I'll give you an example of what I usually do...
1. Restrict access for Administrators (not Super Administrators!) to Modules and Mambots.At about line 136 I comment out the lines below:
// access to modules
//$this->_mos_add_acl( 'administration', 'install', 'users', 'administrator', 'modules', 'all' );
$this->_mos_add_acl( 'administration', 'install', 'users', 'super administrator', 'modules', 'all' );
//$this->_mos_add_acl( 'administration', 'edit', 'users', 'administrator', 'modules', 'all' );
$this->_mos_add_acl( 'administration', 'edit', 'users', 'super administrator', 'modules', 'all' );
// access to mambots
//$this->_mos_add_acl( 'administration', 'install', 'users', 'administrator', 'mambots', 'all' );
$this->_mos_add_acl( 'administration', 'install', 'users', 'super administrator', 'mambots', 'all' );
//$this->_mos_add_acl( 'administration', 'edit', 'users', 'administrator', 'mambots', 'all' );
$this->_mos_add_acl( 'administration', 'edit', 'users', 'super administrator', 'mambots', 'all' );
As you can see, all lines that refer to "administrator" have been commented out. So whenever I open a new user account and give Administrator rights to it, I know they will never see the Modules and Mambots menus!
2. Give Managers and Administrators access to certain components.At about line 152, below where it says:
// uncomment following to allow managers to edit modules
//array( 'administration', 'edit', 'users', 'manager', 'modules', 'all' );
replace the following code:
// access to components
$this->_mos_add_acl( 'administration', 'install', 'users', 'administrator', 'components', 'all' );
$this->_mos_add_acl( 'administration', 'install', 'users', 'super administrator', 'components', 'all' );
$this->_mos_add_acl( 'administration', 'edit', 'users', 'super administrator', 'components', 'all' );
$this->_mos_add_acl( 'administration', 'edit', 'users', 'administrator', 'components', 'all' );
$this->_mos_add_acl( 'administration', 'edit', 'users', 'manager', 'components', 'com_newsflash' );
$this->_mos_add_acl( 'administration', 'edit', 'users', 'manager', 'components', 'com_frontpage' );
$this->_mos_add_acl( 'administration', 'edit', 'users', 'manager', 'components', 'com_media' );
// ** add additional components for a manager as desired, or give access to all
with these lines:
// Custom Access - Start
// added for administrators' access
$this->_mos_add_acl( 'administration', 'install', 'users', 'administrator', 'components', 'all' );
$this->_mos_add_acl( 'administration', 'edit', 'users', 'administrator', 'components', 'com_massmail' );
$this->_mos_add_acl( 'administration', 'manage', 'users', 'administrator', 'components', 'com_massmail' );
$this->_mos_add_acl( 'administration', 'manage', 'users', 'administrator', 'components', 'com_trash' );
$this->_mos_add_acl( 'administration', 'edit', 'users', 'administrator', 'components', 'com_poll' );
$this->_mos_add_acl( 'administration', 'edit', 'users', 'administrator', 'components', 'com_media' );
$this->_mos_add_acl( 'administration', 'edit', 'users', 'administrator', 'components', 'com_joomfish' );
$this->_mos_add_acl( 'administration', 'edit', 'users', 'administrator', 'components', 'com_yanc' );
$this->_mos_add_acl( 'administration', 'edit', 'users', 'administrator', 'components', 'com_artbanners' );
$this->_mos_add_acl( 'administration', 'edit', 'users', 'administrator', 'components', 'com_virtuemart' );
// added for managers' access
$this->_mos_add_acl( 'administration', 'install', 'users', 'manager', 'components', 'all' );
$this->_mos_add_acl( 'administration', 'edit', 'users', 'manager', 'components', 'com_massmail' );
$this->_mos_add_acl( 'administration', 'manage', 'users', 'manager', 'components', 'com_massmail' );
$this->_mos_add_acl( 'administration', 'manage', 'users', 'manager', 'components', 'com_trash' );
$this->_mos_add_acl( 'administration', 'edit', 'users', 'manager', 'components', 'com_poll' );
$this->_mos_add_acl( 'administration', 'edit', 'users', 'manager', 'components', 'com_joomfish' );
$this->_mos_add_acl( 'administration', 'edit', 'users', 'manager', 'components', 'com_artbanners' );
// Custom Access - End
So this way we enabled access to Administrators to: massmail, trash manager, polls, media manager, Joom!Fish, ArtBanners, YaNC and VirtueMart.
And to Managers we enabled access to: massmail, trash manager, polls, Joom!Fish and ArtBanners, but NOT YaNC or VirtueMart (media manager access is given below as standard). Something that was not possible with standard Joomla! user access control.
ConclusionThat way we can easily "distribute" access permission rights for certain components to 2 user groups (Administrators and Managers) without the need for a third-party component!
Please note that there are some core restrictions to certain user groups by default in Joomla! that cannot be affected by the above "hacks". For example, Managers do not handle User Management or cannot access Global Configuration.
But in most cases, all you'll ever need is give access to your site managers to third-party components and probably restrict Administrators from "playing around" with Modules or Mambots.