Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
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.
Hire Txp Builders – finely-crafted code, design and Txp
Online
#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.
Hire Txp Builders – finely-crafted code, design and Txp
Online
#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.
Hire Txp Builders – finely-crafted code, design and Txp
Online
#37 2009-10-04 21:01:18
- Gerich
- Member
- Registered: 2009-08-30
- Posts: 35
Re: customise the interface for certain admin users
Well, I need another part of help.
I want to hide chosen categories from dropdown list in “article” write tab and also image categories in images edit mode page from specified users.
Bloke, maybe you can tell me which part of code I can change to add this future to plugin?
Offline
#38 2009-11-24 21:49:39
- Gerich
- Member
- Registered: 2009-08-30
- Posts: 35
Re: customise the interface for certain admin users
I still hope for your help with categories, Bloke.
Simply to hide them also, as well as sections.
Offline