A.L.E.C wrote:
> I think it would be good start for plugins API to get rid of
> hardcoded actions from index.php.
Absolutely!
> My proposition is to create file for each action (filename =
> actionname) in tasks directories, and then we have:
>
> foreach(array('plugins', 'steps') as $dir) if
> (file_exists('program/'.$dir.'/'.$RCMAIL->task.'/'.$RCMAIL->action.'.inc'))
> { @include_once('program/'.$dir.'/'.$RCMAIL->task.'/_init.inc'); //
> init actions (renamed func.inc)
>
> @include_once('program/'.$dir.'/'.$RCMAIL->task.'/'.$RCMAIL->action.'.inc');
> @include_once('program/'.$dir.'/'.$RCMAIL->task.'/_destroy.inc'); //
> post actions break; }
>
>
> plugins directory it's just for possibility to overwrite built-in
> action with plugin action.
This works fine as long as you validate the $RCMAIL->task variable and
it only works for a single plugin.
And instead of focusing on files I'd recommend creating a plugin
directory that contains a well-defined "init.php" file which then
registers calls to plugin handlers (that's how Squirrelmail does it -
and it works quite well).
Another way is to override classes, like Typo3 does, but this has the
drawback that some constellations don't work together.
My recommendation would be something like this:
/myplugin/init.php:
init_plugin('init', 'functionname');
init_plugin('showmail', 'functionname');
That way the plugin does not have to provide empty files - and using the
@ is not a good coding practice - instead do a file_exists!
My 2 cents.
Mike
--
Michael Baierl
<http://mbaierl.com/>
- - - - - - - - - - - - - - - - -
"Mr. Spock, the women on your planet are logical. That's the only planet
in the galaxy that can make that claim." - Captain Kirk
_______________________________________________
List info: http://lists.roundcube.net/dev/