Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
14 posts Page 1 of 2
hi all,

I have 3 admins:
1 - superadmin --- k_user_access_level: 10 --- k_user_id: 1
2 - admin (special) --- k_user_access_level: 7 --- k_user_id: 2
3 - admin (special) --- k_user_access_level: 7 --- k_user_id: 3

question is:
i have templates:
/root
- index.php
- gallery.php
- news.php

how to allow admin( k_user_id: 3 ) to admin edit only gallery.php and news.php templates in admin panel? for index.php template he should to see something like "You have no permissions" or just in admin panel in left side index.php template should to hide..

another admins can access in admin panel to all templates, but third admin can access only to gallery and news templates in admin panel
Hi,

Out of the box, only admins can access the admin-panel and once inside all admins have equal access.

That said, if you are using Couch v2.0, I think it shouldn't be too difficult to cook up a little addon that enforces the kind of 'template based' access control you want.

Please let me know and I'll get you that. Thanks.
Hi KK,
yes, template based access will be great
OK :)
Please give me a little time though.
I'll try to code it up this weekend.

Thanks.
hi KK, maybe you have a news for me?


KK wrote: OK :)
Please give me a little time though.
I'll try to code it up this weekend.

Thanks.
Hi andrejprus,

Apologies for the delay but here is the promised addon.
It is an extremely simple one but should do exactly what you wanted (i.e. restrict access to specific portions of the admin-panel to certain admins).

Let us begin by installing it.
Extract the attached zip and place the 'simple-access-control' folder it yields into 'couch/addon'.
Activate this addon the usual way i.e. make an entry in 'addons/kfunctions.php' like this -
Code: Select all
require_once( K_COUCH_DIR.'addons/simple-access-control/simple-access-control.php' );

With the addon installed, let us configure the access restrictions for the admin-panel.
For doing that, you'll find a file named 'config.example.php' within this addon's folder (i.e. within 'addons/simple-access-control').
Please rename it to 'config.php'.

Within this config file you can add entries for all 'restricted access' templates.
For example, suppose you have three admins - 'admin', 'jane' and 'joe'. Further suppose that you wish a template named 'settings.php' to be accessible to only 'admin'. For that place the following entry in the config file -
Code: Select all
$t['settings.php'] = 'admin';

And now only the user 'admin' would be able to access the 'settings' template. All other users having access to the admin-panel ('jane' and 'joe' in our example) will simply not see this template listed in the sidebar. Further more, if they try to access the template by typing in its URL directly, they'll get an 'Access denied' message.

Taking the example scenario further, suppose there is a template named 'news.php' and you wish to keep out 'jane' from it. To do so, add the following line to the config -
Code: Select all
$t['news.php'] = 'admin | joe';

As you can see, we are specifying a list of users who are *allowed* access to the template (using a 'pipe' character to separate multiple names). Since the name 'jane' does not figure in the list, she will not be able to access this template in the admin-panel.

As the last example, consider the following entry in config -
Code: Select all
$t['blog.php'] = '';

Here the list of users allowed access to 'blog.php' is left blank. This will translate to no access to anybody (not even the super-admin).
Conversely, if there is a template which should be accessible to everybody, simply leave it out from the config file.

Point being, that if a template has its entry in the config file, this addon will enforce access restriction on it allowing only the explicitly specified users access to it.

Please try configuring access control to your admin-panel as described and let us know how it goes.
Hope you find this addon useful :)

P.S. Needless to say, this addon will require atleast Couch v2.0 to work.

Attachments

Hi KK,
yes, all is great, thank you very much !
Now, this is all cool. Full respect, KK.
Thank you :)
I am glad you found it useful.
KK wrote: Thank you :)
I am glad you found it useful.


this is great, thank you.

is there a way to have the group name the template was assigned to be hidden if no templates are hidden or have a way for us to manually add _groupnames_ to the config add-on file as to hide groups when we know they will be empty for some users?

thanks.
14 posts Page 1 of 2

Who is online

In total there are 2 users online :: 0 registered, 0 hidden and 2 guests
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 2 guests