From: p d. t. <pdo...@an...> - 2005-04-20 00:43:30
|
WJCarpenter wrote: > The plugin guidelines (http://www.squirrelmail.org/wiki/en_US/DevelopingPlugins) > says this about the plugin _init_ function: > > Please note that as of SquirrelMail 1.5.0, should be changed to something more. not sure if it'll get into 1.5.2, but my feeling is that I probably argue strongly for doing so, since plugin architecture changes with templating being implemented will already mean many changes for plugin authors, so we should just do it all at once. > this function will no > longer be called at run time and will instead be called only once at > configure- time. Thus, the inclusion of any dynamic code (anything > except hook registration) here is strongly discouraged. > > Does this in any way mean that a plugin couldn't dynamically register > or unregister from some hooks? well the text above may not be 100% correct. it might turn out that the hook registration is still *somewhat* dynamic, but it hasn't been implemented yet, save for Jimmy's example, so we can't say for sure. > I'm thinking of a case where a plugin > wants to let a user choose via a preference when they would like a > certain action to be done. you need not unregister the hook for that. just check the user pref at the start of the function that is hooked in at that point. > I was thinking that _init_ would just > register with some sure bet hook, and the method called by that hook > would sniff around the preferences or whatever else to make the final > determination about the hooks. sure bet hook for what? most hooks are context sensitive and you usually can't count on some hook being called every time. best it gets is the patched hook that comes with multilogin plugin. > Is the upcoming _init_ scheme at odds with that? maybe, but again, you should make your plugin register like a normal plugin to reduce chances of coding and compatibility nightmare and then check user prefs in the actual functions that do the work. |