[geeklog-devel] plugin_autoinstall - two more issues

Joe Mucchiello joe at ThrowingDice.com
Mon Oct 5 20:46:52 EDT 2009


At 12:30 PM 10/5/2009, Blaine Lang wrote:
>2) If a plugin needs to create multiple groups, they will be created 
>fine but the plugin_doautoinstall only will create the 
>group_assignments records for the first created group. Is there a 
>reason the code to create group_assignment records does not loop 
>through the $groups array?

In case it helps, I rewrote this code into an entirely separate 
library for glFusion. Whether or not you want to look at the code I 
wrote, the approach I took could help. I made each part of the array 
returned by plugin_autoinstall_foo it's own function. If the function 
was successful, it returned a string containing a SQL statement that 
would undo whatever that function just did. This value is assigned 
into a list of strings. If at any time there was an error installing 
the plugin, you simply run the list backwards to repair the database. 
Another part of the approach was to flatten the array and include a 
type field so the install library is extensible: if 
(function_exists('installer_'.$item['type']) { //call that func} Data 
loading statements are included in the array in case they do things 
that need to be reversed. Yes, that's more work for the plugin writer 
but the added safety during install outweighs that to me.

http://glfusion.svn.sourceforge.net/viewvc/glfusion/glfusion/releases/release-1.1.6/private/system/lib-install.php?view=markup

And an example of the array. Note that whether a group is added to 
the admin group is done with 'addroot'=>true on the group line. Also 
notice that groups can be added to other groups in this setup.
http://glfusion.svn.sourceforge.net/viewvc/glfusion/pm/releases/release-1.1.0/autoinstall.php?view=markup 
Lines 45-60, lines 69-85 become the boilerplate code for running the install.




----
Joe Mucchiello
Throwing Dice Games
http://www.throwingdice.com 




More information about the geeklog-devel mailing list