Restricting CB Menu Options in Backend

16 years 4 months ago #53782 by TheDonSansone
Restricting CB Menu Options in Backend was created by TheDonSansone
I have had the need to restrict certain CB menu options within the admin backend so that Managers and Standard Administrators can not see the plugins list; the Tools; and the Configuration settings.

I have JACL installed and was hoping to be able to use this to restrict the menu options which the CB Comprofiler menu would display to my backend moderators / administrators - but couldn't find a solution. It would either show all CB menu links or non at all using JACL.:unsure:

So I hacked 2x of the CB files directly where the components make the function call. It means that the menu items still display - but I can now choose what to show the moderators on the page instead of the CB plugins, tools and configuration settings.

If there is a better way and I can actually hide the indivdual menu items - please help me out here and show me how?B)
This is how I solved my problem:

When selecting the CB Menu option Configuration the URL link is index2.php?option=com_comprofiler&task=showconfig so by searching down the function "showConfig" in the admin.comprofiler.controller.php file I added an If / Else statement to the beginning of the function....

[code:1]function showConfig( $option ) {
global $_CB_database,$ueConfig,$acl,$my,$mainframe;
global $_PLUGINS, $_CB_adminpath, $mainframe;

/** TheDon's Admin Menu Option Fix
*/

$passid = intval( $my->id );

if ((int)$passid != 22 ) {
echo '<br /><br />There is nothing worth listing on this config page! ';
} else {


/** END ==== TheDon's Admin Menu Option Fix
*/


$configfile = $_CB_adminpath."/ue_config.php";
@chmod ($configfile, 0766);[/code:1]

and because of the 'Else' part of the code addition it was necessary to add a closing } at the end of the function thus:

[code:1] HTML_comprofiler::showConfig( $ueConfig, $lists, $option );
}

/** Ultracom's Admin Menu Option Fix
*/

}
/** END ==== Ultracom's Admin Menu Option Fix
*/




function saveConfig ( $option ) {
global $_CB_adminpath;

$configfile = $_CB_adminpath."/ue_config.php";[/code:1]

Basically what I have done is checked if the logged in user has a user id of 22. If the user id is not 22 then only show (echo) a text line saying "There is nothing worth listing on this config page!" otherwise show everything as normal just for the user with the id 22. Each registered user of the site has a unique user id allocated to them, by looking up my SQL USERS table I can choose whichever id's I wish to allow content to be displayed.

I know that this is a hack to the original code, so I have made a note of the few functions that I have added this 'if/else' option to [eg. function showTools() ] incase I update CB in the future and need to add this function back in to the php files.

Like I said, if anybody has a better way of doing this I'd be interested in knowing the answer?
Thanks, TheDon

Post edited by: TheDonSansone, at: 2008/01/07 15:08

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.153 seconds

Facebook Twitter LinkedIn