Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#25 2009-08-31 21:57:09
- Gerich
- Member
- Registered: 2009-08-30
- Posts: 35
Re: customise the interface for certain admin users
I have made all as you have told, but unfortunately, nothing works. Could you show an example code how to hide some sections “name1,name2” (in dropdown list in Write tab) from users with the rights 5 for example?
Offline
#26 2009-08-31 23:56:18
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: customise the interface for certain admin users
Are you using txp 4.2.0?
I realized some hours ago that it ships with jquery 1.3.2 while txp 4.0.8 used v.1.2.6.
The code I posted works with jquery 1.2.6.
You have two alternatives now (if you’re using txp 4.2.0 as I believe):
1) replace jquery.js (under yoursite/textpattern) with jquery version 1.2.6
2) wait till I find what’s the problem and fix it (I hope soon)
Offline
#27 2009-09-01 09:25:23
- Gerich
- Member
- Registered: 2009-08-30
- Posts: 35
Re: customise the interface for certain admin users
redbot wrote:
Are you using txp 4.2.0?
I realized some hours ago that it ships with jquery 1.3.2 while txp 4.0.8 used v.1.2.6.
The code I posted works with jquery 1.2.6.
You have two alternatives now (if you’re using txp 4.2.0 as I believe):
1) replace jquery.js (under yoursite/textpattern) with jquery version 1.2.6
2) wait till I find what’s the problem and fix it (I hope soon)
Yes, I’m using txp 4.2.0.
I have replaced jquery with 1.2.6, but it didn’t take’s effect on your plugin. At last it take’s effect on plugin rah_section_titles, that didn’t work with jquery 1.3.2 too.
I shall wait, when you and other plugin authors will make them compatible to the new version of txp.
Offline
Re: customise the interface for certain admin users
I have written a tiny plugin specifically for 4.2.0 that hides sections from groups of users (it does it per privilege level). It removes sections from the dropdown list on the Write tab. Since rah_section_titles overrides the choices you make in this plugin I also made it possible to choose names or titles.
But it’s not pretty. You hard-code the section lists at the top of the plugin, you have to choose names/titles by editing the plugin, and if you want to also remove articles from those sections in the Article List, it requires a one-line core hack (at the moment).
Also, if you run rah_section_titles, sed_section_fields or adi_menu, the plugin won’t work unless those plugins are removed/patched. I’ve patched the latter two, although sed_sf should really be rewritten to take advantage of the new 4.2.0 features and make it play nicer with other plugins.
What this boils down to is that it’s a little early for this kind of functionality because of all the dependencies and older plugins that have yet to be updated. I won’t release my plugin in its current form because it’s embarrassingly neanderthal — though somehow elegant (and minuscule) in its implementation thanks to the shiny new UI callbacks.
But if anybody wants any specific functionality from this plugin for the time being, ask and I’ll post bits of the code here so you can try it yourselves — with no support/warranty implied of course ;-)
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
Offline
#29 2009-09-01 13:16:32
- Gerich
- Member
- Registered: 2009-08-30
- Posts: 35
Re: customise the interface for certain admin users
Bloke,
yes, I want to test your plugin, which can make these things. It’s exactly what I need.
Offline
#30 2009-09-01 13:18:21
- redbot
- Plugin Author
- Registered: 2006-02-14
- Posts: 1,410
Re: customise the interface for certain admin users
Gerich wrote:
I have replaced jquery with 1.2.6, but it didn’t take’s effect on your plugin. At last it take’s effect on plugin rah_section_titles, that didn’t work with jquery 1.3.2 too.
Strange. It works for me. Have you tried disabling temporarily rah_section_titles?
As Bloke said before, the two plugins are probably interfering.
If disabling rah_section_titles works it should be easy for me to post here a modified version of my plugin which makes the two work together.
Oops! Bloke was faster (and for sure is far more reliable than me ;)).
Last edited by redbot (2009-09-01 13:32:33)
Offline
Re: customise the interface for certain admin users
Gerich wrote:
yes, I want to test your plugin, which can make these things. It’s exactly what I need.
OK, in its simplest form, this is what you need. Make a plugin (use ied_plugin_composer for this if you wish) and put the following code in:
register_callback('smd_filtlist_article_section', 'article_ui', 'section');
global $smd_filtlist_exclusions;
// -----------------------------------------------------------
// Configure which section _names_ to exclude per priv level.
// Each level has its own row and the sections should be listed like this:
// level => array('section1', 'section2', ...),
$smd_filtlist_exclusions = array(
0 => array(), // None (unused)
1 => array(), // Publisher
2 => array(), // Managing Editor
3 => array(), // Copy editor
4 => array(), // Staff writer
5 => array(), // Freelancer
6 => array(), // Designer
);
// -----------------------------------------------------------
function smd_filtlist_article_section($step, $event, $orig, $data) {
global $smd_filtlist_exclusions;
$priv = smd_filtlist_priv();
$selSec = empty($data['Section']) ? getDefaultSection() : $data['Section'];
$rs = safe_column('title', 'txp_section', "name != 'default' AND name NOT IN (".doQuote(join("','", $smd_filtlist_exclusions[$priv])).") ORDER BY name");
if ($rs) {
return n.graf('<label for="section">'.gTxt('section').'</label> '.
'<span class="small">['.eLink('section', '', '', '', gTxt('edit')).']</span>'.br.
selectInput('Section', $rs, $selSec, false, '', 'section')).
n.'</fieldset>';
} else {
return '</fieldset>';
}
}
function smd_filtlist_priv() {
global $txp_user;
$authinfo = safe_row('*', 'txp_users', "name = '$txp_user'");
return $authinfo['privs'];
}
Set up the list of sections you wish to exclude for each priv level, as detailed in the code, enable the plugin and visit the Write tab. You’ll see the sections you specified missing. If you want the section names to be shown instead of the titles, change $rs = safe_column('title', ...
to $rs = safe_column('name', ...
Note that the plugin takes no account of ‘static’ sections as defined by sed_section_fields and will not work with adi_menu or rah_section_titles enabled. See how you get on.
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
Offline
#32 2009-09-01 15:43:30
- Gerich
- Member
- Registered: 2009-08-30
- Posts: 35
Re: customise the interface for certain admin users
Bloke,
Finally it’s working for me (even with jquery 1.3.2). Big thanks!
It was easy and simple to configure it. Your plug-in replaces others two. Continue to develop and improve your plug-in in the future.
And I have another question: is it possible to hide categories in category dropdown list like we did it with sections? Is it easy or hard to add this part of code?
Last edited by Gerich (2009-09-01 19:18:45)
Offline
Re: customise the interface for certain admin users
Gerich
Glad it worked for ya. It’s rough round the edges but it was a quick plugin to solve a specific problem so I didn’t put all the usual bells and whistles in.
is it possible to hide categories in category dropdown list like we did it with sections?
Yes it’s possible and fairly easy I think. It’d be pretty much a copy of the code above with different variable names, hooked into a different part of the Write tab. Though it depends what you want to actually do with the categories dropdowns. If it’s a straight hiding from both category1 and category2 then it’s easy, but if you want anything more involved — like categories depending on the chosen section, or setting certain categories in category1 and a different list in category2 — then it becomes trickier.
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
Offline
#34 2009-09-01 21:01:33
- Gerich
- Member
- Registered: 2009-08-30
- Posts: 35
Re: customise the interface for certain admin users
Bloke wrote:
hiding from both category1 and category2 then it’s easy
I need only this. The situation is: I have many categories named A,B,C,D… all the alphabet which is intended for service articles in specific section. The user should not appoint to use these categories and so more he will get confused between them and other categories.
Offline
#35 2009-09-06 20:28:21
- Gerich
- Member
- Registered: 2009-08-30
- Posts: 35
Re: customise the interface for certain admin users
Bloke wrote:
If you want the section names to be shown instead of the titles, change
$rs = safe_column('title', ...
to$rs = safe_column('name', ...
I have some problem with this. I thought that it will affect only on display of sections in the dropdown list. But, as it has appeared, article is published in section with Title, for example, “the Earth”, but such section does not exist, because its name “Planet” and title “the Earth”. As a result I receive an error 404 when I go to article url.
In my case the problem becomes more essential because I write titles of sections in Russian, and names in Latin letters.
Offline
Re: customise the interface for certain admin users
Gerich wrote:
as it has appeared, article is published in section with Title
D’oh! Sorry, bogus information. If you want titles to display you should use this instead:
...
$rs = safe_rows('name,title', 'txp_section', "name != 'default' AND name NOT IN (".doQuote(join("','", $smd_filtlist_exclusions[$priv])).") ORDER BY name");
if ($rs) {
$sels = array();
foreach ($rs as $row) {
$sels[$row['name']] = $row['title'];
}
return n.graf('<label for="section">'.gTxt('section').'</label> '.
'<span class="small">['.eLink('section', '', '', '', gTxt('edit')).']</span>'.br.
selectInput('Section', $sels, $selSec, false, '', 'section')).
n.'</fieldset>';
} else {
return n.'</fieldset>';
}
...
I wasn’t paying attention when I wrote that bit, apologies :-)
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
Offline