Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
smd_faux_role: switch priv levels on-the-fly
In response to a request by whaleen this simple plugin adds a dropdown control to your Textpattern admin side allowing nominated users to alter their own priv level. This obviates the need for multiple accounts of different types, repeated logging in/out or having multiple browser tabs & windows open while you are testing a site for functionality. Just switch your own user between priv levels and walk the admin side as the great unwashed.
Since this is pretty dangerous territory for regular users — and the plugin is likely only to be used during testing — there is no pretty configuration interface. You specify the user accounts and placement of the dropdown directly in the plugin code itself. It’s all documented in the help and in the plugin source code so you can’t go wrong.
Download it now. Hope this one proves useful. Thanks to whaleen for the original idea and the incremental improvements that led to the first public version.
Revision history
————————
All available versions and changes are listed here. Each entry indexes the relevant post(s) in the thread to learn about the features.
- 11 Apr 10 | 0.10 | Initial release
- 11 Aug 10 | 0.20 | Requires TXP 4.3.0 ; publisher privs restored on logout (thanks net-carver)
Last edited by Bloke (2010-11-05 09:42:04)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Online
Re: smd_faux_role: switch priv levels on-the-fly
Definitely gonna use this for testing user levels!
Kensington TXP powered rock
Offline
#3 2010-04-12 15:58:42
- masa
- Member
- From: Asturias, Spain
- Registered: 2005-11-25
- Posts: 1,091
Re: smd_faux_role: switch priv levels on-the-fly
Excellent, indeed – another smd-must-have!
Offline
#4 2010-08-06 21:01:04
- net-carver
- Archived Plugin Author
- Registered: 2006-03-08
- Posts: 1,648
Re: smd_faux_role: switch priv levels on-the-fly
Just don’t log out of your account when your priv levels are demoted — you’ll be in for a shock when you log in again. :)
— Steve
Offline
Re: smd_faux_role: switch priv levels on-the-fly
net-carver wrote:
Just don’t log out of your account when your priv levels are demoted — you’ll be in for a shock when you log in again. :)
I tried to fix this last night. You know what; I don’t think it can be fixed at the moment :-(
I added a callback on head_end — the earliest admin-side hook I can get my hands on — and it runs fine on every page. But as soon as you click logout, the callback isn’t fired. My guess is that once you’re on that login page and no plugins are permitted to run, that really is game over. I was hoping to intercept the logout just moments before it did the actual logout procedure so I could revert the current account to Publisher but it’s not possible, afaict.
I wondered if there’s room for an on-logout (and on-login) callback but I’m not sure a plugin would even fire at that point (well, on-logout at least — the other one’s fine). It would have to be very, very early in page execution — before doAuth()
was called — and I’m not sure that’s possible because plugins are always loaded afterwards.
Ideas on ways round this accepted, preferably scrawled on a beermat.
Last edited by Bloke (2010-08-06 21:16:05)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Online
#6 2010-08-06 21:30:06
- net-carver
- Archived Plugin Author
- Registered: 2006-03-08
- Posts: 1,648
Re: smd_faux_role: switch priv levels on-the-fly
Hmmm. A couple of non-elegant ideas come to mind…
- Use an output buffer to re-write all the admin-side logout URLs to a handler in your plugin and then have that restore the privs and really logout.
- Have the logout link generated by a function call and add something like a pluggable_ui callback to that. Would need to force all theme authors to update themes to use that function though with some severe consequences if they didn’t — just kidding.
…not pretty. If I have any better ideas I’ll let you know.
— Steve
Offline
Re: smd_faux_role: switch priv levels on-the-fly
net-carver wrote:
Use an output buffer to re-write all the admin-side logout URLs to a handler in your plugin
Actually, you might be onto something here, thanks. A simple bit of jQuery could either:
- attach a handler to the logout link which fires an AJAX request to my plugin before the actual logout is executed
- completely commandeer the logout link to redirect to my plugin, whereupon I do what I need to do and then refresh the page with
?logout=1
on the end
I might try option 1 and see how far I get since it’s the most elegant of the two (assuming it can trigger in time). Option 2 is a fallback.
EDIT: The sticking point might be if a theme has removed the logout link or renamed its ID; the guidelines in the wiki do advise against this but it’s a remote possibility.
Last edited by Bloke (2010-08-06 21:43:19)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Online
#8 2010-08-06 21:49:39
- net-carver
- Archived Plugin Author
- Registered: 2006-03-08
- Posts: 1,648
Re: smd_faux_role: switch priv levels on-the-fly
Stef,
sorry but no inspiration here. You’re right — jQuery is a better option here than an output buffer routine.
— Steve
Offline
Re: smd_faux_role: switch priv levels on-the-fly
v0.20 is out. Requires TXP 4.3.0+
Bug fix to restore the Publisher privs on the currently logged-in account if you hit the logout button. Should stop frustration and having to go into phpMyAdmin to restore your own privs.
Remember to reset your publisher names at the top of the plugin after you’ve upgraded and to set any position offset if you had it set up that way.
Last edited by Bloke (2010-11-05 09:44:01)
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Online
Re: smd_faux_role: switch priv levels on-the-fly
I am no longer able to login and see my Admin, Extensions, Plugins, etc tabs.
I was testing out various access options using Switch Role plugin, and while i was switched to “Staff Writer” I logout… but when i try to logon again as Admin my Admin ID is still stuck i nstaff writer!! I can i reset. I can’t login to see admin tabs?
NOTE: i have 0.20 installed
(‘smd_faux_role’,1,‘Stef Dawson’,‘stefdawson.com/’,‘0.20’,‘Switch user privs on the fly so you can see what other accounts see’
…. texted postive
Offline
Re: smd_faux_role: switch priv levels on-the-fly
bici wrote:
I am no longer able to login and see my Admin, Extensions, Plugins, etc tabs.
Heck! You’ll probably have to alter your main login ID from phpMAdmin to set the privs to 1. I guess the failsafe javascript that resets your login back to admin doesn’t hook properly into 4.5.x so it’s not very failsafe any more. Sorry about that. I’ll see if I can fix it asap.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Online
Re: smd_faux_role: switch priv levels on-the-fly
Bloke wrote:
bici wrote:
I am no longer able to login and see my Admin, Extensions, Plugins, etc tabs.
Heck! You’ll probably have to alter your main login ID from phpMAdmin to set the privs to 1. I guess the failsafe javascript that resets your login back to admin doesn’t hook properly into 4.5.x so it’s not very failsafe any more. Sorry about that. I’ll see if I can fix it asap.
Hi – i was able to regain access via phpMyAdmin ( reset to 1 for my ID)
i am now using smd_user_manager
Last edited by bici (2012-11-18 18:46:33)
…. texted postive
Offline