a) I've updated my original hack so check it out please to see what has changed.
b) Ok, nice challenge meekochan!
This is for Joomla! 1.0.12Here we go...
To add the possibility of hiding modules for a certain user group (i.e. Authors, Publishers, Managers etc.) this is what is needed:
1) In your
/modules/[whatever_module].xml you need to add the following somewhere within the
section:
Code:
<param name="show_registered" type="radio" default="1" label="Show Menu When Logged In" description="Show the menu also when a registered user is logged in">
<option value="0">No</option>
<option value="1">Yes</option>
</param>
<param name="hide_for_gid" type="list" default="0" label="Hide Module for this User Type Only" description="If above is set to 'No', you can specify which registered user type you want to hide this module for. Default hides the module for any logged in user.">
<option value="0">Default</option>
<option value="18">Registered</option>
<option value="19">Author</option>
<option value="20">Editor</option>
<option value="21">Publisher</option>
<option value="23">Manager</option>
<option value="24">Administrator</option>
<option value="25">Super Administrator</option>
<option value=">19">Author and above</option>
<option value=">20">Editor and above</option>
<option value=">21">Publisher and above</option>
<option value=">23">Manager and above</option>
<option value=">24">Administrator and above</option>
<option value="<19">Author and below</option>
<option value="<20">Editor and below</option>
<option value="<21">Publisher and below</option>
<option value="<23">Manager and below</option>
<option value="<24">Administrator and below</option>
</param>
2) Then in
/includes/frontend.php in function
&initModules() on line 73 change the global line to:
Code:
global $database, $my, $Itemid, $acl;
(added $acl to the variables)
3) Further down in the same function, replace this code:
Code:
foreach ($modules as $module) {
$GLOBALS['_MOS_MODULES'][$module->position][] = $module;
}
with this code:
Code:
// HACK: to hide modules for certain groups of logged in users
$myRealGid = intval($acl->get_group_id($my->usertype));
// --- end HACK ---
foreach ($modules as $module) {
// HACK: added code to check if module should be shown when a user is logged in and is in a particular group
$params = new mosParameters( $module->params );
if (!$params->get('show_registered', 1) && $my->id) {
// check the gid if param set
if ($params->get('hide_for_gid', 0) != '0') {
if (strlen($params->get('hide_for_gid')) > 2) {
// if we're looking at ranges, extract the comparator and the gid to compare
$comparator = substr($params->get('hide_for_gid'), 0, 1);
$hideGid = intval(substr($params->get('hide_for_gid'), 1));
if (($comparator == ">" && $myRealGid >= $hideGid) || ($comparator == "<" && $myRealGid <= $hideGid)) {
continue;
}
} elseif (intval($params->get('hide_for_gid')) == $myRealGid) {
// if the user's gid is equal to the parameter, hide the module
continue;
}
} else {
// simply continue the loop without outputting this module
continue;
}
}
// --- end HACK ---
$GLOBALS['_MOS_MODULES'][$module->position][] = $module;
}
And it's done. You can then set for which kinds of registered users you want the module to be hidden. The parameter list allows you to specify the exact level (i.e. Authors only) or a range like "hide for Editors and above" or "hide for Managers and below" which hides the module for that level user and above/below.
Hope this is useful to some of you, as always, enjoy.
Edit: Just realised that the option: "Registered and below" doesn't make sense (cos it's the same as "Default") so I removed it

.