Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-02-19 13:40:30

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

bot_admin_body_class

This micro-plugin let’s you hide items in txp backend based on the logged user name and privilege level, via css.
Once activated it simply adds two classes to the body tag of each tab via jquery:

  • One indicates the user group of the current logged user
  • Another indicates the logged user

For example if I log in as “Donald Swain” with “managing editor” privileges, the “body” tag for every txp admin page will now have two more classes: “managing_editor” and “donald_swain”.
Please note that the user name will be lowercased and spaces will be replaced with an underscore.

Privileges can be one of the following:

  • publisher
  • managing_editor
  • copy_editor
  • staff_writer
  • freelancer
  • designer
  • none

Once done that, you can easily hide items in the admin adding some css rules in your textpattern.css file.

For example:

body.managing_editor .override-form {display:none;}

will hide the “override form” field for each user logged as managing editor.
In the same vein

body.donald_swain .override-form {display:none;}

Will do the same but only if you are logged in as Donald Swain.

The idea for this plugin comes from sacripant

Info and download

Last edited by redbot (2011-02-27 16:24:29)

Offline

#2 2011-02-19 15:59:14

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: bot_admin_body_class

Neat and simple. Great work redbot :-)

Offline

#3 2011-02-19 16:22:43

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: bot_admin_body_class

Gocom wrote:

Neat and simple. Great work redbot :-)

Thank you maestro

Offline

#4 2011-02-19 20:07:36

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,271

Re: bot_admin_body_class

Very cool stuff! Again! Thanks, Luca!

And a »Nice idea!« to Sacripant!

@ all: Let me advertise the advent of the Paypal button on the site of a guy who deserves some of our virtual thankfulness :)

Last edited by uli (2011-02-19 20:11:50)


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#5 2011-02-19 20:10:38

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: bot_admin_body_class

uli wrote:

Very cool stuff! Again! Thanks, Luca!

Thanks uli ;-)

Offline

#6 2011-02-21 11:02:03

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: bot_admin_body_class

Perfect,
Small, but allows much.
I think I’ll always install by default.

Now there are css class, I suggest you do the splits :D
Merging with bwt_customize :
rearrange and style items in the write tab, hide them on a per section basis and remove sections from the “write” tab sections dropdown per group (and user ?)

It’s just another idea.

Offline

#7 2011-02-21 20:52:36

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: bot_admin_body_class

sacripant wrote:

rearrange and style items in the write tab, hide them on a per section basis and remove sections from the “write” tab sections dropdown per group (and user ?)

Hi sacripant,
I fear this would be overly complicated and all in all not worthwhile.
I’ll split my answer:

… rearrange and style items

I think that’s not an issue. I can’t imagine a situation where you would need to rearrange items on a per-user basis (for example why you would move the ‘excerpt’ field before the ‘body’ field only for specific users?)

… hide them on a per section basis

Again, the two plugins can work perfectly together and cover all possible scenarios I can imagine.

….remove sections from the “write” tab sections dropdown per group (and user ?)

That’s the only case in which your request makes sense for me… but if you know a little jquery you can easily achieve it writing some custom rules in bot_wtc and taking advantage of the classes created by bot_body_class.
In case ask me how in the appropriate forum thread.

Offline

#8 2011-02-22 08:05:07

Dragondz
Moderator
From: Algérie
Registered: 2005-06-12
Posts: 1,469
Website GitHub Twitter

Re: bot_admin_body_class

Very interesting plugin, now we can specify a category or a section for dedicated user or group (adding some code to your plugin) that’s very cool!

Thanks redbot

Offline

#9 2011-02-22 10:09:49

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: bot_admin_body_class

Again, the two plugins can work perfectly together and cover all possible scenarios I can imagine.

I agree. I am bridged

Just I remember, some users were asked if bwt_customise could hide sections for some users
One TxpTips could help users who do not know JavaScript or Jquery.

Offline

#10 2011-02-27 19:58:18

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: bot_admin_body_class

What happens if a logged in user has JS switched off? Idle of me to ask, I know, when I could try it out myself.

Offline

#11 2011-02-27 20:08:36

redbot
Plugin Author
Registered: 2006-02-14
Posts: 1,410

Re: bot_admin_body_class

joebaich wrote:

What happens if a logged in user has JS switched off? Idle of me to ask, I know, when I could try it out myself.

Hi Joe,
of course the plugin won’t work. This is a simple plugin which aims at providing a better user exeprience hiding fields which are not useful for some users. It’s not meant to grant user privileges.

P.S. the plugin won’t work even if css is turned off.

Offline

#12 2011-02-27 22:37:58

joebaich
Member
From: DC Metro Area and elsewhere
Registered: 2006-09-24
Posts: 507
Website

Re: bot_admin_body_class

Yes, I was really just thinking aloud. I have a user who knows how to disable JS in his browser and uses how well his website performs without it as a proxy measure of the efficiency of everything else (and the state of the universe). So glad he can’t disable the CSS.

A good bit of work though and, you are right, no reason why it can’t improve the experience for other users.

Last edited by joebaich (2011-02-27 22:39:49)

Offline

Board footer

Powered by FluxBB