1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 13:17:24 +02:00

plugin.xml now supports a pre and post custom function for install, upgrade, or uninstall

This commit is contained in:
mcfly
2008-02-02 00:48:58 +00:00
parent 2dbb895b5a
commit c84601294d
2 changed files with 38 additions and 21 deletions

View File

@@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/plugin_class.php,v $
| $Revision: 1.24 $
| $Date: 2008-02-01 18:09:01 $
| $Revision: 1.25 $
| $Date: 2008-02-02 00:48:57 $
| $Author: mcfly_e107 $
+----------------------------------------------------------------------------+
*/
@@ -633,6 +633,9 @@ class e107plugin
return false;
}
// Let's call any custom pre functions defined in <management> section
$this->execute_function($path, $function, 'pre');
// tables
// This will load each _sql.php file found in the plugin directory and parse it.
if(($function == 'install' || $function == 'uninstall') && count($sql_list))
@@ -786,24 +789,8 @@ class e107plugin
$this -> manage_search($function, $plug_vars['folder']);
$this -> manage_notify($function, $plug_vars['folder']);
// Let's call any custom functions defined in <management> section
if(isset($plug_vars['management'][$function]))
{
$manage = $plug_vars['management'][$function]['@attributes'];
if(is_readable($path.$manage['file']))
{
include($path.$manage['file']);
if($manage['type'] == 'fileFunction')
{
$result = call_user_func($manage['function'], $plug_vars);
}
elseif($manage['type'] == 'classFunction')
{
$_tmp = new $manage['class'];
$result = call_user_func(array($_tmp, $manage['function']), $plug_vars);
}
}
}
// Let's call any custom post functions defined in <management> section
$this->execute_function($path, $function, 'post');
if($function == 'install' || $functon = 'upgrade')
{
@@ -822,7 +809,36 @@ class e107plugin
$text .= $plug_vars['installDone'];
}
}
}
function execute_function($path = '', $what='', $when='')
{
if($what == '' || $when == '') { return true; }
if(!isset($this->plug_vars['management'][$what])) { return true; }
$vars = $this->plug_vars['management'][$what];
if(!is_array($vars)) { $vars = array($vars); }
foreach($vars as $var)
{
$attrib = $var['@attributes'];
if(isset($attrib['when']) && $attrib['when'] == $when)
{
if(is_readable($path.$attrib['file']))
{
include_once($path.$attrib['file']);
if($attrib['type'] == 'fileFunction')
{
$result = call_user_func($attrib['function'], $plug_vars);
return $result;
}
elseif($attrib['type'] == 'classFunction')
{
$_tmp = new $attrib['class'];
$result = call_user_func(array($_tmp, $attrib['function']), $plug_vars);
return $result;
}
}
}
}
}
function parse_prefs($pref_array)

View File

@@ -39,7 +39,8 @@
<userclass name="forum_moderator" description="Moderator of all forums" />
</userclasses>
<management>
<install type="classFunction" file="forum_management.php" class="forum_management" function="forum_install" />
<install when="pre" type="classFunction" file="forum_management.php" class="forum_management" function="forum_install_pre" />
<install when="post" type="classFunction" file="forum_management.php" class="forum_management" function="forum_install_post" />
<uninstall type="classFunction" file="forum_management.php" class="forum_management" function="forum_uninstall" />
<upgrade type="classFunction" file="forum_management.php" class="forum_management" function="forum_upgrade" />
</management>