Hey all, I'm wondering if there are some docs that explain how to create a new tab for preferences, where if you click on the tab, you get a listbox where multiple plugins could register for a row. Basically imitating how the settings-tab works. Ideally the plugins would not have to worry about the tab, but could just register their own section on that tab.
Am I going to have to reverse engineer how the settings-tab does this, and code this all myself, or is there some existing structure I could use?
Regards,
Cor
Looks like I need to just create this myself. I need to do this because our settings area is getting cluttered with internal spam/virus/whitelist/blacklist etc settings, and I want to create 1 tab that holds them all.
Would it be useful if I made a plugin that does nothing but create a new tab, and allows other plugins to register on that tab? Where the tab name and hook name would be configurable? Not sure if other people would have a use for this.
Regards,
Cor
On 09/13/2013 01:15 PM, Cor Bosman wrote:
Looks like I need to just create this myself.
Are you talking about preferences sections? Kolab Calendar plugin does what you want. See http://git.kolab.org/roundcubemail-plugins-kolab/tree/plugins/calendar/calen...
With these three hooks you can create a section and add content to any section.
Cor Bosman wrote:
Hey all, I'm wondering if there are some docs that explain how to create a new tab for preferences, where if you click on the tab, you get a listbox where multiple plugins could register for a row. Basically imitating how the settings-tab works. Ideally the plugins would not have to worry about the tab, but could just register their own section on that tab.
For creating a new tab, use the container object named "tabs" to append content either using PHP or javascript. Look at existing plugins such as managesieve [1] or passwords [2].
The general settings tab already provides a hook to add more section: 'preferences_sections_list' [3].
If I understood correctly you want to add another tab that would offer a similar hook for plugins to register settings? This doesn't make sense to me because that already exists.
Kind regards, Thomas
[1] http://trac.roundcube.net/browser/github/plugins/managesieve/managesieve.js [2] http://trac.roundcube.net/browser/github/plugins/password/password.js#L9 [3] http://trac.roundcube.net/wiki/Plugin_Hooks#preferences_list
On Sep 14, 2013, at 11:49 AM, Thomas Bruederli thomas@roundcube.net wrote:
Cor Bosman wrote:
Hey all, I'm wondering if there are some docs that explain how to create a new tab for preferences, where if you click on the tab, you get a listbox where multiple plugins could register for a row. Basically imitating how the settings-tab works. Ideally the plugins would not have to worry about the tab, but could just register their own section on that tab.
For creating a new tab, use the container object named "tabs" to append content either using PHP or javascript. Look at existing plugins such as managesieve [1] or passwords [2].
The general settings tab already provides a hook to add more section: 'preferences_sections_list' [3].
If I understood correctly you want to add another tab that would offer a similar hook for plugins to register settings? This doesn't make sense to me because that already exists.
It exists under 'general'. But ive got about 7 plugins dealing with internal spam/virus settings. Some have their own tab, some are in general. Think spamfilter settings, virus filter on/off, whitelists, blacklists, etc. I want to consolidate all these plugins under 1 new tab named 'Spam/Virus settings' or whatever (under larry this is much more useful than under classic, as larry has plenty of vertical space for 'tabs'). I think this is more logical than having a 'turn spamfilter on' setting under 'general', but a whitelist editor under its own tab.
I can create a tab, no problem. Many of my plugins do that :)
I can create a new section under general, no problem.
But I want pluggable sections under a new tab :)
Anyways, what im doing now is i made a plugin that creates a new tab, and has a hook where plugins can register for a section. This works fine. Im seeing a set of plugins. But then I also have to make my own preferences_list and preferences_save unfortunately. Unless there is some trick im missing on how i could re-use those settings functions.
For a visual, see http://grab.by/qgRO (as you can see, my own preferences_list is already working, but id rather not duplicate code).
ps: Alec, in light of people that may want to integrate spam filters in roundcube, your managesieve "Filters" tab is a little confusing I think.
Cor
Cor Bosman wrote:
On Sep 14, 2013, at 11:49 AM, Thomas Bruederli thomas@roundcube.net wrote:
Cor Bosman wrote:
Hey all, I'm wondering if there are some docs that explain how to create a new tab for preferences, where if you click on the tab, you get a listbox where multiple plugins could register for a row. Basically imitating how the settings-tab works. Ideally the plugins would not have to worry about the tab, but could just register their own section on that tab.
For creating a new tab, use the container object named "tabs" to append content either using PHP or javascript. Look at existing plugins such as managesieve [1] or passwords [2].
The general settings tab already provides a hook to add more section: 'preferences_sections_list' [3].
If I understood correctly you want to add another tab that would offer a similar hook for plugins to register settings? This doesn't make sense to me because that already exists.
It exists under 'general'. But ive got about 7 plugins dealing with internal spam/virus settings. Some have their own tab, some are in general. Think spamfilter settings, virus filter on/off, whitelists, blacklists, etc. I want to consolidate all these plugins under 1 new tab named 'Spam/Virus settings' or whatever (under larry this is much more useful than under classic, as larry has plenty of vertical space for 'tabs'). I think this is more logical than having a 'turn spamfilter on' setting under 'general', but a whitelist editor under its own tab.
I can create a tab, no problem. Many of my plugins do that :)
I can create a new section under general, no problem.
But I want pluggable sections under a new tab :)
Understood.
Anyways, what im doing now is i made a plugin that creates a new tab, and has a hook where plugins can register for a section. This works fine. Im seeing a set of plugins. But then I also have to make my own preferences_list and preferences_save unfortunately. Unless there is some trick im missing on how i could re-use those settings functions.
You could make your plugin hook into the 'preferences_sections_list' and 'preferences_list' hooks and re-arrange the items that have been added by the plugins you want to gather. Just make sure your plugin is loaded "after" the others that should make it receive the hook events at the end.
~Thomas
I can create a tab, no problem. Many of my plugins do that :)
I can create a new section under general, no problem.
But I want pluggable sections under a new tab :)
Understood.
Anyways, what im doing now is i made a plugin that creates a new tab, and has a hook where plugins can register for a section. This works fine. Im seeing a set of plugins. But then I also have to make my own preferences_list and preferences_save unfortunately. Unless there is some trick im missing on how i could re-use those settings functions.
You could make your plugin hook into the 'preferences_sections_list' and 'preferences_list' hooks and re-arrange the items that have been added by the plugins you want to gather. Just make sure your plugin is loaded "after" the others that should make it receive the hook events at the end.
Could you elaborate? What do you mean by re-arrange?
I can actually get this to work, if I let my 7 plugins hook into both the preferences_sections_list, and my own plugin section list. Then I see the plugins on my own tab, and I can click on them, and if my new tab plugin javascript calls the normal edit-prefs action with my own section it all seems to work and I see the edit screen in my iframe.
Only issue now is, i see these 7 plugins on the general tab as well. I could hide this with css maybe, but you seem to suggest I could do something else. I dont quite see what yet :) It seems the plugins have to be listed in preferences_section_list, else edit_prefs.inc doesnt actually find the plugin.
$CURR_SECTION = get_input_value('_section', RCUBE_INPUT_GPC); list($SECTIONS,) = rcmail_user_prefs($CURR_SECTION); <-- my plugin doesnt end up in this array if I dont hook my plugin into preferences_sections_list.
Cor
Only issue now is, i see these 7 plugins on the general tab as well. I could hide this with css maybe, but you seem to suggest I could do something else. I dont quite see what yet :) It seems the plugins have to be listed in preferences_section_list, else edit_prefs.inc doesnt actually find the plugin.
Oh, I could of course just not do add_hook if im in the preferences action. That actually seems to work.. Awesome. Now my plugins are found by edit-prefs and save-prefs but not when I click on the general tab.
Cor
On Sat, Sep 14, 2013 at 4:03 PM, Cor Bosman cor@xs4all.nl wrote:
I can create a tab, no problem. Many of my plugins do that :)
I can create a new section under general, no problem.
But I want pluggable sections under a new tab :)
Understood.
Anyways, what im doing now is i made a plugin that creates a new tab, and has a hook where plugins can register for a section. This works fine. Im seeing a set of plugins. But then I also have to make my own preferences_list and preferences_save unfortunately. Unless there is some trick im missing on how i could re-use those settings functions.
You could make your plugin hook into the 'preferences_sections_list' and 'preferences_list' hooks and re-arrange the items that have been added by the plugins you want to gather. Just make sure your plugin is loaded "after" the others that should make it receive the hook events at the end.
Could you elaborate? What do you mean by re-arrange?
I'm sorry, unfortunately I didn't think that all through before answering. Adding tabs is mostly done client side which is hard or even impossible to intercept. And those plugins that add a new tabs usually have their own skin templates that would not fit into the iframe you have for "regular" preferences.
In short: I guess there's no way around a custom hook defined by your plugin which is explicitly used by the other plugins you want to gather.
Regards, Thomas
I'm sorry, unfortunately I didn't think that all through before answering. Adding tabs is mostly done client side which is hard or even impossible to intercept. And those plugins that add a new tabs usually have their own skin templates that would not fit into the iframe you have for "regular" preferences.
In short: I guess there's no way around a custom hook defined by your plugin which is explicitly used by the other plugins you want to gather.
I figured. Is there a reason that 'tabs' are done client side? I can sort of understand from the classic perspective, but in larry the tabs are much more useful and we should maybe encourage its use more. Would be cool to add tabs through a normal PHP hook, and even cooler if you then also get section support automatically (if you want it, some plugins may want to use the full page).
Cor