1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-01 12:20:44 +02:00

plugin.xml support completed (I hope)

This commit is contained in:
mcfly
2008-02-02 22:04:18 +00:00
parent 39f7ced05a
commit 114ea53cf0
3 changed files with 273 additions and 343 deletions

View File

@@ -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_admin/plugin.php,v $ | $Source: /cvs_backup/e107_0.8/e107_admin/plugin.php,v $
| $Revision: 1.11 $ | $Revision: 1.12 $
| $Date: 2008-02-01 14:11:27 $ | $Date: 2008-02-02 22:04:18 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -144,125 +144,108 @@ if ($action == 'uninstall')
$id = intval($id); $id = intval($id);
$plug = $plugin->getinfo($id); $plug = $plugin->getinfo($id);
$text = '';
//Uninstall Plugin //Uninstall Plugin
if ($plug['plugin_installflag'] == TRUE ) if ($plug['plugin_installflag'] == TRUE )
{ {
include(e_PLUGIN.$plug['plugin_path'].'/plugin.php'); $_path = e_PLUGIN.$plug['plugin_path'].'/';
if(file_exists($_path.'plugin.xml'))
$func = $eplug_folder.'_uninstall';
if (function_exists($func))
{ {
$text .= call_user_func($func); $text .= $plugin->manage_plugin_xml($id, 'uninstall');
}
if($_POST['delete_tables'])
{
if (is_array($eplug_table_names))
{
$result = $plugin->manage_tables('remove', $eplug_table_names);
if ($result !== TRUE)
{
$text .= EPL_ADLAN_27.' <b>'.$mySQLprefix.$result.'</b> - '.EPL_ADLAN_30.'<br />';
}
else
{
$text .= EPL_ADLAN_28."<br />";
}
}
} }
else else
{ {
$text .= EPL_ADLAN_49."<br />"; include(e_PLUGIN.$plug['plugin_path'].'/plugin.php');
}
$func = $eplug_folder.'_uninstall';
if (is_array($eplug_prefs)) if (function_exists($func))
{
$plugin->manage_prefs('remove', $eplug_prefs);
$text .= EPL_ADLAN_29."<br />";
}
if (is_array($eplug_comment_ids))
{
$text .= ($plugin->manage_comments('remove', $eplug_comment_ids)) ? EPL_ADLAN_50."<br />" : "";
}
if ($eplug_module)
{
$plugin->manage_plugin_prefs('remove', 'modules', $eplug_folder);
}
if ($eplug_status)
{
$plugin->manage_plugin_prefs('remove', 'plug_status', $eplug_folder);
}
if ($eplug_latest)
{
$plugin->manage_plugin_prefs('remove', 'plug_latest', $eplug_folder);
}
if (is_array($eplug_array_pref))
{
foreach($eplug_array_pref as $key => $val)
{ {
$plugin->manage_plugin_prefs('remove', $key, $eplug_folder, $val); $text .= call_user_func($func);
} }
}
if($_POST['delete_tables'])
if (is_array($eplug_sc))
{
$plugin->manage_plugin_prefs('remove', 'plug_sc', $eplug_folder, $eplug_sc);
}
if (is_array($eplug_bb))
{
$plugin->manage_plugin_prefs('remove', 'plug_bb', $eplug_folder, $eplug_bb);
}
if (is_array($eplug_user_prefs))
{
if (!is_object($sql)){ $sql = new db; }
$sql->db_Select("core", " e107_value", " e107_name='user_entended'");
$row = $sql->db_Fetch();
$user_entended = unserialize($row[0]);
$user_entended = array_values(array_diff($user_entended, array_keys($eplug_user_prefs)));
if ($user_entended == NULL)
{ {
$sql->db_Delete("core", "e107_name='user_entended'"); if (is_array($eplug_table_names))
{
$result = $plugin->manage_tables('remove', $eplug_table_names);
if ($result !== TRUE)
{
$text .= EPL_ADLAN_27.' <b>'.$mySQLprefix.$result.'</b> - '.EPL_ADLAN_30.'<br />';
}
else
{
$text .= EPL_ADLAN_28."<br />";
}
}
} }
else else
{ {
$tmp = addslashes(serialize($user_entended)); $text .= EPL_ADLAN_49."<br />";
$sql->db_Update("core", "e107_value='$tmp' WHERE e107_name='user_entended' ");
} }
while (list($key, $e_user_pref) = each($eplug_user_prefs))
if (is_array($eplug_prefs))
{ {
unset($user_pref[$key]); $plugin->manage_prefs('remove', $eplug_prefs);
$text .= EPL_ADLAN_29."<br />";
}
if (is_array($eplug_comment_ids))
{
$text .= ($plugin->manage_comments('remove', $eplug_comment_ids)) ? EPL_ADLAN_50."<br />" : "";
}
if ($eplug_module)
{
$plugin->manage_plugin_prefs('remove', 'modules', $eplug_folder);
}
if ($eplug_status)
{
$plugin->manage_plugin_prefs('remove', 'plug_status', $eplug_folder);
}
if ($eplug_latest)
{
$plugin->manage_plugin_prefs('remove', 'plug_latest', $eplug_folder);
}
if (is_array($eplug_array_pref))
{
foreach($eplug_array_pref as $key => $val)
{
$plugin->manage_plugin_prefs('remove', $key, $eplug_folder, $val);
}
}
if (is_array($eplug_sc))
{
$plugin->manage_plugin_prefs('remove', 'plug_sc', $eplug_folder, $eplug_sc);
}
if (is_array($eplug_bb))
{
$plugin->manage_plugin_prefs('remove', 'plug_bb', $eplug_folder, $eplug_bb);
}
if ($eplug_menu_name)
{
$sql->db_Delete('menus', "menu_name='$eplug_menu_name' ");
}
if ($eplug_link)
{
$plugin->manage_link('remove', $eplug_link_url, $eplug_link_name);
}
if ($eplug_userclass)
{
$plugin->manage_userclass('remove', $eplug_userclass);
} }
save_prefs("user");
} }
if ($eplug_menu_name) $plugin->manage_search('remove', $eplug_folder);
{
$sql->db_Delete('menus', "menu_name='$eplug_menu_name' ");
}
if ($eplug_link) $plugin->manage_notify('remove', $eplug_folder);
{
$plugin->manage_link('remove', $eplug_link_url, $eplug_link_name);
}
if ($eplug_userclass)
{
$plugin->manage_userclass('remove', $eplug_userclass);
}
$plugin -> manage_search('remove', $eplug_folder);
$plugin -> manage_notify('remove', $eplug_folder);
$sql->db_Update('plugin', "plugin_installflag=0, plugin_version='{$eplug_version}' WHERE plugin_id='{$id}' "); $sql->db_Update('plugin', "plugin_installflag=0, plugin_version='{$eplug_version}' WHERE plugin_id='{$id}' ");
if (isset($pref['plug_installed'][$plug['plugin_path']])) if (isset($pref['plug_installed'][$plug['plugin_path']]))
@@ -270,181 +253,152 @@ if ($action == 'uninstall')
unset($pref['plug_installed'][$plug['plugin_path']]); unset($pref['plug_installed'][$plug['plugin_path']]);
save_prefs(); save_prefs();
} }
if($_POST['delete_files'])
{
include_once(e_HANDLER."file_class.php");
$fi = new e_file;
$result = $fi->rmtree(e_PLUGIN.$eplug_folder);
$text .= ($result ? "<br />All files removed from ".e_PLUGIN.$eplug_folder : '<br />File deletion failed<br />'.EPL_ADLAN_31.' <b>'.e_PLUGIN.$eplug_folder.'</b> '.EPL_ADLAN_32);
}
else
{
$text .= '<br />'.EPL_ADLAN_31.' <b>'.e_PLUGIN.$eplug_folder.'</b> '.EPL_ADLAN_32;
}
$ns->tablerender(EPL_ADLAN_1.' '.$tp->toHtml($eplug_name,"","defs,emotes_off, no_make_clickable"), $text);
$text = "";
$plugin -> save_addon_prefs();
} }
if($_POST['delete_files'])
{
include_once(e_HANDLER."file_class.php");
$fi = new e_file;
$result = $fi->rmtree(e_PLUGIN.$eplug_folder);
$text .= ($result ? "<br />All files removed from ".e_PLUGIN.$eplug_folder : '<br />File deletion failed<br />'.EPL_ADLAN_31.' <b>'.e_PLUGIN.$eplug_folder.'</b> '.EPL_ADLAN_32);
}
else
{
$text .= '<br />'.EPL_ADLAN_31.' <b>'.e_PLUGIN.$eplug_folder.'</b> '.EPL_ADLAN_32;
}
$plugin->save_addon_prefs();
$ns->tablerender(EPL_ADLAN_1.' '.$tp->toHtml($plug['plugin_name'], "", "defs,emotes_off,no_make_clickable"), $text);
$text = '';
} }
if ($action == 'install') if ($action == 'install')
{ {
$plugin->install_plugin(intval($id)); $text = $plugin->install_plugin($id);
$plugin ->save_addon_prefs(); $plugin ->save_addon_prefs();
// if($eplug_conffile){ $text .= "&nbsp;<a href='".e_PLUGIN."$eplug_folder/$eplug_conffile'>[".LAN_CONFIGURE."]</a>"; }
$ns->tablerender(EPL_ADLAN_33, $text);
} }
if ($action == 'upgrade') if ($action == 'upgrade')
{ {
$plug = $plugin->getinfo($id); $plug = $plugin->getinfo($id);
include(e_PLUGIN.$plug['plugin_path'].'/plugin.php');
$_path = e_PLUGIN.$plug['plugin_path'].'/';
$func = $eplug_folder.'_upgrade'; if(file_exists($_path.'plugin.xml'))
if (function_exists($func))
{ {
$text .= call_user_func($func); $text .= $plugin->manage_plugin_xml($id, 'upgrade');
}
if (is_array($upgrade_alter_tables))
{
$result = $plugin->manage_tables('upgrade', $upgrade_alter_tables);
if (!$result)
{
$text .= EPL_ADLAN_9.'<br />';
}
else
{
$text .= EPL_ADLAN_7."<br />";
}
}
if ($eplug_module)
{
$plugin->manage_plugin_prefs('add', 'modules', $eplug_folder);
} }
else else
{ {
$plugin->manage_plugin_prefs('remove', 'modules', $eplug_folder); include(e_PLUGIN.$plug['plugin_path'].'/plugin.php');
}
$func = $eplug_folder.'_upgrade';
if ($eplug_status) if (function_exists($func))
{
$plugin->manage_plugin_prefs('add', 'plug_status', $eplug_folder);
}
else
{
$plugin->manage_plugin_prefs('remove', 'plug_status', $eplug_folder);
}
if ($eplug_latest)
{
$plugin->manage_plugin_prefs('add', 'plug_latest', $eplug_folder);
}
else
{
$plugin->manage_plugin_prefs('remove', 'plug_latest', $eplug_folder);
}
if (is_array($upgrade_add_eplug_sc))
{
$plugin->manage_plugin_prefs('add', 'plug_sc', $eplug_folder, $eplug_sc);
}
if (is_array($upgrade_remove_eplug_sc))
{
$plugin->manage_plugin_prefs('remove', 'plug_sc', $eplug_folder, $eplug_sc);
}
if (is_array($upgrade_add_eplug_bb))
{
$plugin->manage_plugin_prefs('add', 'plug_bb', $eplug_folder, $eplug_bb);
}
if (is_array($upgrade_remove_eplug_bb))
{
$plugin->manage_plugin_prefs('remove', 'plug_bb', $eplug_folder, $eplug_bb);
}
if (is_array($upgrade_add_prefs))
{
$plugin->manage_prefs('add', $upgrade_add_prefs);
$text .= EPL_ADLAN_8.'<br />';
}
if (is_array($upgrade_remove_prefs))
{
$plugin->manage_prefs('remove', $upgrade_remove_prefs);
}
if (is_array($upgrade_add_array_pref))
{
foreach($upgrade_add_array_pref as $key => $val)
{ {
$plugin->manage_plugin_prefs('add', $key, $eplug_folder, $val); $text .= call_user_func($func);
} }
}
if (is_array($upgrade_alter_tables))
if (is_array($upgrade_remove_array_pref))
{
foreach($upgrade_remove_array_pref as $key => $val)
{ {
$plugin->manage_plugin_prefs('remove', $key, $eplug_folder, $val); $result = $plugin->manage_tables('upgrade', $upgrade_alter_tables);
if (!$result)
{
$text .= EPL_ADLAN_9.'<br />';
}
else
{
$text .= EPL_ADLAN_7."<br />";
}
} }
}
if ($eplug_module)
if (is_array($upgrade_add_user_prefs))
{
if (!is_object($sql)){ $sql = new db; }
$sql->db_Select("core", " e107_value", " e107_name='user_entended'");
$row = $sql->db_Fetch();
$user_entended = unserialize($row[0]);
while (list($key, $e_user_pref) = each($eplug_user_prefs))
{ {
$user_entended[] = $e_user_pref; $plugin->manage_plugin_prefs('add', 'modules', $eplug_folder);
}
$tmp = addslashes(serialize($user_entended));
if ($sql->db_Select("core", " e107_value", " e107_name='user_entended'"))
{
$sql->db_Update("core", "e107_value='$tmp' WHERE e107_name='user_entended' ");
} }
else else
{ {
$sql->db_Insert("core", "'user_entended', '$tmp' "); $plugin->manage_plugin_prefs('remove', 'modules', $eplug_folder);
} }
$text .= EPL_ADLAN_8."<br />";
} if ($eplug_status)
if (is_array($upgrade_remove_user_prefs))
{
if (!is_object($sql)){ $sql = new db; }
$sql->db_Select("core", " e107_value", " e107_name='user_entended'");
$row = $sql->db_Fetch();
$user_entended = unserialize($row[0]);
$user_entended = array_values(array_diff($user_entended, $eplug_user_prefs));
if ($user_entended == NULL)
{ {
$sql->db_Delete("core", "e107_name='user_entended'"); $plugin->manage_plugin_prefs('add', 'plug_status', $eplug_folder);
} }
else else
{ {
$tmp = addslashes(serialize($user_entended)); $plugin->manage_plugin_prefs('remove', 'plug_status', $eplug_folder);
$sql->db_Update("core", "e107_value='$tmp' WHERE e107_name='user_entended' ");
} }
if ($eplug_latest)
{
$plugin->manage_plugin_prefs('add', 'plug_latest', $eplug_folder);
}
else
{
$plugin->manage_plugin_prefs('remove', 'plug_latest', $eplug_folder);
}
if (is_array($upgrade_add_eplug_sc))
{
$plugin->manage_plugin_prefs('add', 'plug_sc', $eplug_folder, $eplug_sc);
}
if (is_array($upgrade_remove_eplug_sc))
{
$plugin->manage_plugin_prefs('remove', 'plug_sc', $eplug_folder, $eplug_sc);
}
if (is_array($upgrade_add_eplug_bb))
{
$plugin->manage_plugin_prefs('add', 'plug_bb', $eplug_folder, $eplug_bb);
}
if (is_array($upgrade_remove_eplug_bb))
{
$plugin->manage_plugin_prefs('remove', 'plug_bb', $eplug_folder, $eplug_bb);
}
if (is_array($upgrade_add_prefs))
{
$plugin->manage_prefs('add', $upgrade_add_prefs);
$text .= EPL_ADLAN_8.'<br />';
}
if (is_array($upgrade_remove_prefs))
{
$plugin->manage_prefs('remove', $upgrade_remove_prefs);
}
if (is_array($upgrade_add_array_pref))
{
foreach($upgrade_add_array_pref as $key => $val)
{
$plugin->manage_plugin_prefs('add', $key, $eplug_folder, $val);
}
}
if (is_array($upgrade_remove_array_pref))
{
foreach($upgrade_remove_array_pref as $key => $val)
{
$plugin->manage_plugin_prefs('remove', $key, $eplug_folder, $val);
}
}
$plugin->manage_search('upgrade', $eplug_folder);
$plugin->manage_notify('upgrade', $eplug_folder);
$eplug_addons = $plugin -> getAddons($eplug_folder);
$text .= (isset($eplug_upgrade_done)) ? '<br />'.$eplug_upgrade_done : "<br />".LAN_UPGRADE_SUCCESSFUL;
$sql->db_Update('plugin', "plugin_version ='{$eplug_version}', plugin_addons='{$eplug_addons}' WHERE plugin_id='$id' ");
$pref['plug_installed'][$plug['plugin_path']] = $eplug_version; // Update the version
save_prefs();
} }
$plugin -> manage_search('upgrade', $eplug_folder);
$plugin -> manage_notify('upgrade', $eplug_folder);
$eplug_addons = $plugin -> getAddons($eplug_folder);
$text .= (isset($eplug_upgrade_done)) ? '<br />'.$eplug_upgrade_done : "<br />".LAN_UPGRADE_SUCCESSFUL;
$sql->db_Update('plugin', "plugin_version ='{$eplug_version}', plugin_addons='{$eplug_addons}' WHERE plugin_id='$id' ");
$pref['plug_installed'][$plug['plugin_path']] = $eplug_version; // Update the version
save_prefs();
$ns->tablerender(EPL_ADLAN_34, $text); $ns->tablerender(EPL_ADLAN_34, $text);
$plugin -> save_addon_prefs(); $plugin->save_addon_prefs();
} }

View File

@@ -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.26 $ | $Revision: 1.27 $
| $Date: 2008-02-02 03:23:47 $ | $Date: 2008-02-02 22:04:18 $
| $Author: mcfly_e107 $ | $Author: mcfly_e107 $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -30,16 +30,15 @@ class e107plugin
'eplug_prefs', 'eplug_prefs',
'eplug_array_pref', // missing previously 'eplug_array_pref', // missing previously
'eplug_table_names', 'eplug_table_names',
'eplug_user_prefs',
'eplug_sc', 'eplug_sc',
'eplug_userclass', 'eplug_userclass',
'eplug_module', 'eplug_module',
'eplug_bb', 'eplug_bb',
'eplug_latest', 'eplug_latest',
'eplug_status' //, 'eplug_status',
// 'eplug_comment_ids', // Not sure about this one 'eplug_comment_ids',
// 'eplug_menu_name', // ...or this one 'eplug_conffile',
// 'eplug_conffile' // ...or this one 'eplug_menu_name'
); );
// List of all plugin variables involved in an update (not used ATM, but worth 'documenting') // List of all plugin variables involved in an update (not used ATM, but worth 'documenting')
@@ -51,8 +50,6 @@ class e107plugin
'upgrade_remove_eplug_bb', 'upgrade_remove_eplug_bb',
'upgrade_add_prefs', 'upgrade_add_prefs',
'upgrade_remove_prefs', 'upgrade_remove_prefs',
'upgrade_add_user_prefs',
'upgrade_remove_user_prefs',
'upgrade_add_array_pref', 'upgrade_add_array_pref',
'upgrade_remove_array_pref' 'upgrade_remove_array_pref'
); );
@@ -69,7 +66,7 @@ class e107plugin
var $plug_vars; var $plug_vars;
var $current_plug; var $current_plug;
var $parsed_plugin; var $parsed_plugin;
function e107plugin() function e107plugin()
{ {
$parsed_plugin = array(); $parsed_plugin = array();
@@ -385,10 +382,10 @@ class e107plugin
} }
} }
function manage_comments($action, $comment_id)
function manage_comments($action,$comment_id)
{ {
global $sql, $tp; global $sql, $tp;
$tmp = array();
if($action == 'remove') if($action == 'remove')
{ {
foreach($comment_id as $com) foreach($comment_id as $com)
@@ -396,11 +393,11 @@ class e107plugin
$tmp[] = "comment_type='".$tp -> toDB($com, true)."'"; $tmp[] = "comment_type='".$tp -> toDB($com, true)."'";
} }
$qry = implode(" OR ",$tmp); $qry = implode(" OR ",$tmp);
return $sql->db_Delete('comments',$qry); echo $qry."<br />";
return $sql->db_Delete('comments', $qry);
} }
} }
function manage_tables($action, $var) function manage_tables($action, $var)
{ {
global $sql; global $sql;
@@ -604,10 +601,11 @@ class e107plugin
$id = (int)$id; $id = (int)$id;
$plug = $this->getinfo($id); $plug = $this->getinfo($id);
$this->current_plug = $plug; $this->current_plug = $plug;
$txt = '';
$path = e_PLUGIN.$plug['plugin_path'].'/'; $path = e_PLUGIN.$plug['plugin_path'].'/';
//We'll just install using plugin.php file for now. //We'll just install using plugin.php file for now.
return $this->install_plugin_php($path); //return $this->install_plugin_php($path);
//New code to install using plugin.xml below. //New code to install using plugin.xml below.
$addons = explode(',', $plug['plugin_addons']); $addons = explode(',', $plug['plugin_addons']);
@@ -637,7 +635,7 @@ class e107plugin
} }
// Let's call any custom pre functions defined in <management> section // Let's call any custom pre functions defined in <management> section
$this->execute_function($path, $function, 'pre'); $txt .= $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.
@@ -650,18 +648,20 @@ class e107plugin
preg_match_all("/create(.*?)myisam.*?;/si", $sql_data, $result ); preg_match_all("/create(.*?)myisam.*?;/si", $sql_data, $result );
foreach ($result[0] as $sql_table) foreach ($result[0] as $sql_table)
{ {
if($function == 'uninstall') preg_match("/CREATE TABLE(.*?)\(/si", $sql_table, $match);
$tablename = trim($match[1]);
if($function == 'uninstall' && isset($_POST['delete_tables']) && $_POST['delete_tables'])
{ {
preg_match("/CREATE TABLE(.*?)\(/si", $sql_table, $match); $txt .= "Removing table $tablename <br />";
$tablename = trim($match[1]);
echo "Removing table $tablename <br />";
$this->manage_tables('remove', array($tablename)); $this->manage_tables('remove', array($tablename));
} }
if($function == 'install') if($function == 'install')
{ {
$sql_table = preg_replace("/create table\s+/si", "CREATE TABLE #", $sql_table); $sql_table = preg_replace("/create table\s+/si", "CREATE TABLE ".MPREFIX, $sql_table);
echo "Adding table: <pre>{$sql_table}</pre><br />"; $txt .= "Adding table: {$tablename} ... ";
$this->manage_tables('add', array($sql_table)); $result = $this->manage_tables('add', array($sql_table));
$txt .= ($result ? "Success" : "Failed!")."<br />";
} }
} }
} }
@@ -687,20 +687,20 @@ class e107plugin
if(!isset($attrib['active']) || $attrib['active'] == 'true') if(!isset($attrib['active']) || $attrib['active'] == 'true')
{ {
$perm = (isset($attrib['perm']) ? $attrib['perm'] : 0); $perm = (isset($attrib['perm']) ? $attrib['perm'] : 0);
echo "Adding link {$attrib['name']} with url [{$attrib['url']}] and perm {$perm} <br />"; $txt .= "Adding link {$attrib['name']} with url [{$attrib['url']}] and perm {$perm} <br />";
$this->manage_link('add', $attrib['url'], $attrib['name'], $perm); $this->manage_link('add', $attrib['url'], $attrib['name'], $perm);
} }
//remove inactive links on upgrade //remove inactive links on upgrade
if($function == 'upgrade' && isset($attrib['active']) && $attrib['active'] == 'false') if($function == 'upgrade' && isset($attrib['active']) && $attrib['active'] == 'false')
{ {
echo "Removing link {$attrib['name']} with url [{$attrib['url']}] <br />"; $txt .= "Removing link {$attrib['name']} with url [{$attrib['url']}] <br />";
$this->manage_link('remove', $attrib['url'], $attrib['name']); $this->manage_link('remove', $attrib['url'], $attrib['name']);
} }
break; break;
case 'uninstall': case 'uninstall':
//remove all links //remove all links
echo "Removing link {$attrib['name']} with url [{$attrib['url']}] <br />"; $txt .= "Removing link {$attrib['name']} with url [{$attrib['url']}] <br />";
$this->manage_link('remove', $attrib['url'], $attrib['name']); $this->manage_link('remove', $attrib['url'], $attrib['name']);
break; break;
} }
@@ -719,14 +719,14 @@ class e107plugin
case 'upgrade': case 'upgrade':
if(is_array($list['active'])) if(is_array($list['active']))
{ {
echo "Adding prefs ".print_a($list['active'], true)."<br />"; $txt .= "Adding prefs ".print_a($list['active'], true)."<br />";
$this->manage_prefs('add', $list['active']); $this->manage_prefs('add', $list['active']);
} }
//If upgrading, removing any inactive pref //If upgrading, removing any inactive pref
if($function == 'upgrade' && is_array($list['inactive'])) if($function == 'upgrade' && is_array($list['inactive']))
{ {
echo "Removing prefs ".print_a($list['inactive'], true)."<br />"; $txt .= "Removing prefs ".print_a($list['inactive'], true)."<br />";
$this->manage_prefs('remove', $list['inactive']); $this->manage_prefs('remove', $list['inactive']);
} }
break; break;
@@ -735,7 +735,7 @@ class e107plugin
case 'uninstall': case 'uninstall':
if(is_array($list['all'])) if(is_array($list['all']))
{ {
echo "Removing prefs ".print_a($list['all'], true)."<br />"; $txt .= "Removing prefs ".print_a($list['all'], true)."<br />";
$this->manage_prefs('remove', $list['all']); $this->manage_prefs('remove', $list['all']);
} }
break; break;
@@ -745,55 +745,53 @@ class e107plugin
//Userclasses //Userclasses
//$this->manage_userclass('add', $eplug_userclass, $eplug_userclass_description); //$this->manage_userclass('add', $eplug_userclass, $eplug_userclass_description);
if(isset($plug_vars['userclasses'])) if(isset($plug_vars['userclass']))
{ {
if(isset($plug_vars['userclasses']['userclass'])) $uclass_list = (isset($plug_vars['userclass'][0]) ? $plug_vars['userclass'] : array($plug_vars['userclass']));
foreach($uclass_list as $uclass)
{ {
if(!isset($plug_vars['userclasses']['userclass'][0])) $attrib = $uclass['@attributes'];
switch($function)
{ {
$uclass_list = array($plug_vars['userclasses']['userclass']); case 'install':
} case 'upgrade':
else // Add all active userclasses
{ if(!isset($attrib['active']) || $attrib['active'] == 'true')
$uclass_list = $plug_vars['userclasses']['userclass'];
}
foreach($uclass_list as $uclass)
{
$attrib = $uclass['@attributes'];
switch($function)
{ {
case 'install': $txt .= "Adding userclass ".$attrib['name']."<br />";
case 'upgrade': $this->manage_userclass('add', $attrib['name'], $attrib['description']);
// Add all active userclasses
if(!isset($attrib['active']) || $attrib['active'] == 'true')
{
echo "Adding userclass ".$attrib['name']."<br />";
$this->manage_userclass('add', $attrib['name'], $attrib['description']);
}
//If upgrading, removing any inactive userclass
if($function == 'upgrade' && isset($attrib['active']) && $attrib['active'] == 'false')
{
echo "Removing userclass ".$attrib['name']."<br />";
$this->manage_userclass('remove', $attrib['name'], $attrib['description']);
}
break;
//If uninstalling, remove all userclasses (active or inactive)
case 'uninstall':
echo "Removing prefs ".$attrib['name']."<br />";
$this->manage_userclass('remove', $attrib['name'], $attrib['description']);
break;
} }
//If upgrading, removing any inactive userclass
if($function == 'upgrade' && isset($attrib['active']) && $attrib['active'] == 'false')
{
$txt .= "Removing userclass ".$attrib['name']."<br />";
$this->manage_userclass('remove', $attrib['name'], $attrib['description']);
}
break;
//If uninstalling, remove all userclasses (active or inactive)
case 'uninstall':
$txt .= "Removing userclass ".$attrib['name']."<br />";
$this->manage_userclass('remove', $attrib['name'], $attrib['description']);
break;
} }
} }
} }
//If and commentIDs are configured, we need to remove all comments on uninstall
if($function == 'uninstall' && isset($plug_vars['commentID']))
{
$commentArray = (is_array($plug_vars['commentID']) ? $plug_vars['commentID'] : array($plug_vars['commentID']));
$txt .= "Removing all plugin comments: (".implode(', ', $commentArray).")<br />";
$this->manage_comments('remove', $commentArray);
}
$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 post functions defined in <management> section // Let's call any custom post functions defined in <management> section
$this->execute_function($path, $function, 'post'); $txt .= $this->execute_function($path, $function, 'post');
if($function == 'install' || $functon = 'upgrade') if($function == 'install' || $functon = 'upgrade')
@@ -806,12 +804,13 @@ class e107plugin
if($function == 'install') if($function == 'install')
{ {
$text .= LAN_INSTALL_SUCCESSFUL."<br />"; $txt .= LAN_INSTALL_SUCCESSFUL."<br />";
if(isset($plug_vars['installDone'])) if(isset($plug_vars['installDone']))
{ {
$text .= $plug_vars['installDone']; $txt .= $plug_vars['installDone'];
} }
} }
return $txt;
} }
function execute_function($path = '', $what='', $when='') function execute_function($path = '', $what='', $when='')
@@ -935,29 +934,6 @@ class e107plugin
$this->manage_plugin_prefs('add', 'plug_bb', $eplug_folder, $eplug_bb); $this->manage_plugin_prefs('add', 'plug_bb', $eplug_folder, $eplug_bb);
} }
if (is_array($eplug_user_prefs))
{
$sql->db_Select("core", " e107_value", " e107_name = 'user_entended'");
$row = $sql->db_Fetch();
$user_entended = unserialize($row[0]);
while (list($e_user_pref, $default_value) = each($eplug_user_prefs))
{
$user_entended[] = $e_user_pref;
$user_pref['$e_user_pref'] = $default_value;
}
save_prefs("user");
$tmp = addslashes(serialize($user_entended));
if ($sql->db_Select("core", "e107_value", " e107_name = 'user_entended'"))
{
$sql->db_Update("core", "e107_value = '{$tmp}' WHERE e107_name = 'user_entended' ");
}
else
{
$sql->db_Insert("core", "'user_entended', '{$tmp}' ");
}
$text .= EPL_ADLAN_8."<br />";
}
if ($eplug_link === TRUE && $eplug_link_url != '' && $eplug_link_name != '') if ($eplug_link === TRUE && $eplug_link_url != '' && $eplug_link_name != '')
{ {
$linkperm = (isset($eplug_link_perms) ? $eplug_link_perms : e_UC_PUBLIC); $linkperm = (isset($eplug_link_perms) ? $eplug_link_perms : e_UC_PUBLIC);
@@ -1019,8 +995,7 @@ class e107plugin
{ {
$text = EPL_ADLAN_21; $text = EPL_ADLAN_21;
} }
if($eplug_conffile){ $text .= "&nbsp;<a href='".e_PLUGIN."$eplug_folder/$eplug_conffile'>[".LAN_CONFIGURE."]</a>"; } return $text;
$ns->tablerender(EPL_ADLAN_33, $text);
} }
function save_addon_prefs() function save_addon_prefs()
@@ -1234,7 +1209,7 @@ class e107plugin
include($path.'plugin.php'); include($path.'plugin.php');
$ret = array(); $ret = array();
$ret['installRequired'] = ($eplug_conffile || is_array($eplug_table_names) || is_array($eplug_prefs) || is_array($eplug_user_prefs) || is_array($eplug_sc) || is_array($eplug_bb) || $eplug_module || $eplug_userclass || $eplug_status || $eplug_latest); $ret['installRequired'] = ($eplug_conffile || is_array($eplug_table_names) || is_array($eplug_prefs) || is_array($eplug_sc) || is_array($eplug_bb) || $eplug_module || $eplug_userclass || $eplug_status || $eplug_latest);
$ret['version'] = varset($eplug_version); $ret['version'] = varset($eplug_version);
$ret['name'] = varset($eplug_name); $ret['name'] = varset($eplug_name);

View File

@@ -8,6 +8,8 @@
<compatibility>0.8</compatibility> <compatibility>0.8</compatibility>
<installRequired>true</installRequired> <installRequired>true</installRequired>
<folder>forum</folder> <folder>forum</folder>
<commentID>forum1</commentID>
<commentID>forum2</commentID>
<administration> <administration>
<configFile>forum_admin.php</configFile> <configFile>forum_admin.php</configFile>
<icon>images/forums_32.png</icon> <icon>images/forums_32.png</icon>
@@ -35,9 +37,8 @@
<key name="pref3" value="val3" /> <key name="pref3" value="val3" />
</pref> </pref>
</mainPrefs> </mainPrefs>
<userclasses> <userclass name="forum_moderator" description="Moderator of all forums" />
<userclass name="forum_moderator" description="Moderator of all forums" /> <userclass name="forum_moderator2" description="Moderator of all forums" />
</userclasses>
<management> <management>
<install when="post" type="classFunction" file="forum_management.php" class="forum_management" function="forum_install_post" /> <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" />