mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 21:27:25 +02:00
plugin.xml now supports a pre and post custom function for install, upgrade, or uninstall
This commit is contained in:
@@ -11,8 +11,8 @@
|
|||||||
| GNU General Public License (http://gnu.org).
|
| GNU General Public License (http://gnu.org).
|
||||||
|
|
|
|
||||||
| $Source: /cvs_backup/e107_0.8/e107_handlers/plugin_class.php,v $
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/plugin_class.php,v $
|
||||||
| $Revision: 1.24 $
|
| $Revision: 1.25 $
|
||||||
| $Date: 2008-02-01 18:09:01 $
|
| $Date: 2008-02-02 00:48:57 $
|
||||||
| $Author: mcfly_e107 $
|
| $Author: mcfly_e107 $
|
||||||
+----------------------------------------------------------------------------+
|
+----------------------------------------------------------------------------+
|
||||||
*/
|
*/
|
||||||
@@ -633,6 +633,9 @@ class e107plugin
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Let's call any custom pre functions defined in <management> section
|
||||||
|
$this->execute_function($path, $function, 'pre');
|
||||||
|
|
||||||
// tables
|
// tables
|
||||||
// This will load each _sql.php file found in the plugin directory and parse it.
|
// This will load each _sql.php file found in the plugin directory and parse it.
|
||||||
if(($function == 'install' || $function == 'uninstall') && count($sql_list))
|
if(($function == 'install' || $function == 'uninstall') && count($sql_list))
|
||||||
@@ -786,24 +789,8 @@ class e107plugin
|
|||||||
$this -> manage_search($function, $plug_vars['folder']);
|
$this -> manage_search($function, $plug_vars['folder']);
|
||||||
$this -> manage_notify($function, $plug_vars['folder']);
|
$this -> manage_notify($function, $plug_vars['folder']);
|
||||||
|
|
||||||
// Let's call any custom functions defined in <management> section
|
// Let's call any custom post functions defined in <management> section
|
||||||
if(isset($plug_vars['management'][$function]))
|
$this->execute_function($path, $function, 'post');
|
||||||
{
|
|
||||||
$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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($function == 'install' || $functon = 'upgrade')
|
if($function == 'install' || $functon = 'upgrade')
|
||||||
{
|
{
|
||||||
@@ -822,7 +809,36 @@ class e107plugin
|
|||||||
$text .= $plug_vars['installDone'];
|
$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)
|
function parse_prefs($pref_array)
|
||||||
|
@@ -39,7 +39,8 @@
|
|||||||
<userclass name="forum_moderator" description="Moderator of all forums" />
|
<userclass name="forum_moderator" description="Moderator of all forums" />
|
||||||
</userclasses>
|
</userclasses>
|
||||||
<management>
|
<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" />
|
<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" />
|
<upgrade type="classFunction" file="forum_management.php" class="forum_management" function="forum_upgrade" />
|
||||||
</management>
|
</management>
|
||||||
|
Reference in New Issue
Block a user