[MOD] - 1.3.4 Admin Menu Controller Access Support
11 posts
• Page 1 of 1
[MOD] - 1.3.4 Admin Menu Controller Access Support
I altered the admin menu controller so that it would only output menu items that the current user has permission for, is this useful to anyone else? Just thought I would share.
The language file variable names need to relate properly to their counterparts in $full_menu, template file needs $menu_items in the appropriate place as well.
Comments/critique?
The language file variable names need to relate properly to their counterparts in $full_menu, template file needs $menu_items in the appropriate place as well.
- Code: Select all
class ControllerCommonMenu extends Controller {
protected function index() {
$this->load->language('common/menu');
$this->data['text_help'] = $this->language->get('text_help');
$this->data['text_support'] = $this->language->get('text_support');
$this->data['text_documentation'] = $this->language->get('text_documentation');
$this->data['text_opencart'] = $this->language->get('text_opencart');
$full_menu = array(
'admin' => array(
'common/home',
'shop',
'configuration' => array(
'setting/setting',
'users' => array(
'user/user',
'user/user_permission'
),
'localisation' => array(
'localisation/language',
'localisation/currency',
'localisation/stock_status',
'localisation/order_status',
'localisation/country',
'localisation/zone',
'localisation/geo_zone',
'localisation/tax_class',
'localisation/measurement_class',
'localisation/weight_class'
),
'tool/error_log',
'tool/backup'
),
'common/logout'
),
'catalog' => array(
'catalog/category',
'catalog/product',
'catalog/manufacturer',
'catalog/download',
'catalog/review',
'catalog/information',
'catalog/featured'
),
'extension' => array(
'extension/module',
'extension/shipping',
'extension/payment',
'extension/total',
'extension/feed'
),
'customers' => array(
'customer/customer',
'customer/customer_group',
'customer/order',
'customer/coupon',
'customer/contact'
),
'reports' => array(
'report/sale',
'report/viewed',
'report/purchased'
)
);
$this->data['menu_items'] = $this->outputMenu($full_menu);
$this->data['logged'] = $this->user->isLogged();
$this->id = 'menu';
$this->template = 'common/menu.tpl';
$this->render();
}
function outputMenu($array, $level = 1, $output = "") {
if (is_array($array)) {
foreach ($array as $key => $value) {
if (is_array($value)) {
if ($level == 1) {
$parent = '<li id="' . $key . '"><a class="top">' . $this->language->get('text_' . $key) . '</a><ul>' . "\n";
}
else {
$parent = '<li><a class="parent">' . $this->language->get('text_' . $key) . '</a><ul>' . "\n";
}
$newoutput = $this->outputMenu($value, 2, $output);
if ($newoutput != $output) {
$output .= $parent;
$output = $this->outputMenu($value, 2, $output);
$output .= "</ul></li>" . "\n";
}
}
elseif ($value == 'shop') {
$output .= '<li><a href="' . HTTP_CATALOG . '">' . $this->language->get('text_shop') . '</a></li>' . "\n";
}
elseif ($value == 'common/home' || $value == 'common/logout') {
$part = explode('/', $value);
$output .= '<li><a href="' . $this->url->http($value) . '">' . $this->language->get('text_' . @$part[1]) . '</a></li>' . "\n";
}
else {
$part = explode('/', $value);
if ($this->user->hasPermission('access', @$part[0] . '/' . @$part[1])) {
$output .= '<li><a href="' . $this->url->http($value) . '">' . $this->language->get('text_' . @$part[1]) . '</a></li>' . "\n";
}
}
}
}
return $output;
}
}
Comments/critique?
- hazpotts
- Posts: 4
- Joined: Mon Feb 08, 2010 12:41 pm
Re: Admin Menu Controller
Someone moved this thread, but I don't see that it is a General Support issue, it's a code snippet offering additional functionality... 

Last edited by Qphoria on Mon Feb 08, 2010 5:27 pm, edited 1 time in total.
Reason: Agreed. We have a "move-happy" mod on staff. I've moved it to contributions now and change the title to mark the [MOD] status.
Reason: Agreed. We have a "move-happy" mod on staff. I've moved it to contributions now and change the title to mark the [MOD] status.
- hazpotts
- Posts: 4
- Joined: Mon Feb 08, 2010 12:41 pm
Re: Admin Menu Controller
hazpotts wrote:Someone moved this thread, but I don't see that it is a General Support issue, it's a code snippet offering additional functionality...
My bad, it was my intention to put it in the Contributions section but I made a mistake and could not find it anymore
Thanks Q!
Norman in 't Veldt
Moderator OpenCart Forums
_________________ READ and Search BEFORE POSTING _________________
Our FREE search: Find your answer FAST!.
First Things First: Opencart Check List.
Documentation: Our Documentation section.
BUGs?: Known BUGS for All OC Versions.
Problemen met de BTW?: [How to] BTW + Verzend & betaalmethodes.
Moderator OpenCart Forums
_________________ READ and Search BEFORE POSTING _________________
Our FREE search: Find your answer FAST!.
First Things First: Opencart Check List.
Documentation: Our Documentation section.
BUGs?: Known BUGS for All OC Versions.
Problemen met de BTW?: [How to] BTW + Verzend & betaalmethodes.
-

i2Paq - Global Moderator
- Posts: 9764
- Joined: Mon Nov 09, 2009 11:00 am
- Location: Winkel - The Netherlands
Re: [MOD] - 1.4.0 Admin Menu Controller Access Support
this is a great mod but im unsure where to install this? can you point me in the right direction please?
thank you
thank you

- DannyMacD
- Posts: 471
- Joined: Thu Jun 25, 2009 10:39 pm
Re: [MOD] - 1.4.0 Admin Menu Controller Access Support
admin > controller > common > menu.php
I didn't get a notification of your reply, hope this still helps!
I didn't get a notification of your reply, hope this still helps!
- hazpotts
- Posts: 4
- Joined: Mon Feb 08, 2010 12:41 pm
Re: [MOD] - 1.4.0 Admin Menu Controller Access Support
There is no separate menu in 1.4.0 so i have no idea what this is for

Donate!|OpenCart Basics|GeoZones
Help me get more development cloud storage - Click Here to get DropBox
-

Qphoria - Administrator
- Posts: 18209
- Joined: Mon Jul 21, 2008 7:02 pm

Re: [MOD] - 1.4.0 Admin Menu Controller Access Support
I didn't label this 1.4.0, it was for 1.3.4, my bad for not putting that on though I guess, my first attempt to contribute to anything, go easy...
In 1.4.x it would be used in header.php, but I assume it would need editting, I will post an update, if someone could edit my orginal post with it when I do that would be great.
In 1.4.x it would be used in header.php, but I assume it would need editting, I will post an update, if someone could edit my orginal post with it when I do that would be great.
- hazpotts
- Posts: 4
- Joined: Mon Feb 08, 2010 12:41 pm
Re: [MOD] - 1.4.0 Admin Menu Controller Access Support
hazpotts wrote:I didn't label this 1.4.0, it was for 1.3.4, my bad for not putting that on though I guess, my first attempt to contribute to anything, go easy...
In 1.4.x it would be used in header.php, but I assume it would need editting, I will post an update, if someone could edit my orginal post with it when I do that would be great.
Changed the title to 1.3.4
Norman in 't Veldt
Moderator OpenCart Forums
_________________ READ and Search BEFORE POSTING _________________
Our FREE search: Find your answer FAST!.
First Things First: Opencart Check List.
Documentation: Our Documentation section.
BUGs?: Known BUGS for All OC Versions.
Problemen met de BTW?: [How to] BTW + Verzend & betaalmethodes.
Moderator OpenCart Forums
_________________ READ and Search BEFORE POSTING _________________
Our FREE search: Find your answer FAST!.
First Things First: Opencart Check List.
Documentation: Our Documentation section.
BUGs?: Known BUGS for All OC Versions.
Problemen met de BTW?: [How to] BTW + Verzend & betaalmethodes.
-

i2Paq - Global Moderator
- Posts: 9764
- Joined: Mon Nov 09, 2009 11:00 am
- Location: Winkel - The Netherlands
Re: [MOD] - 1.3.4 Admin Menu Controller Access Support
Hello,
I'm trying to do the same on 1.4.8b menu... But I don't get it on this forum...
Do you have a way to follow for do this ?
Or an other topic that I miss ??
I'm going to try to use this code
in header.tpl and I'll see...
I'm trying to do the same on 1.4.8b menu... But I don't get it on this forum...
Do you have a way to follow for do this ?
Or an other topic that I miss ??
I'm going to try to use this code
- Code: Select all
this->user->hasPermission('access', '<the good right>')
in header.tpl and I'll see...
Single we go faster, together we go more away...
-

mfrerebeau - Posts: 21
- Joined: Fri Aug 13, 2010 9:29 am
- Location: France
Re: [MOD] - 1.3.4 Admin Menu Controller Access Support
was there any luck getting this to work? i have now moved over to 1.4.9 and still would love this feature 
thanks

thanks
- DannyMacD
- Posts: 471
- Joined: Thu Jun 25, 2009 10:39 pm
Re: [MOD] - 1.3.4 Admin Menu Controller Access Support
I would love to have this functionality too, thanks for the contribution.
- Mint_Sauce
- Posts: 12
- Joined: Fri Sep 10, 2010 1:01 pm
11 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 3 guests













