mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 20:58:30 +01:00
plugin.xml support completed (I hope)
This commit is contained in:
parent
39f7ced05a
commit
114ea53cf0
@ -11,8 +11,8 @@
|
||||
| GNU General Public License (http://gnu.org).
|
||||
|
|
||||
| $Source: /cvs_backup/e107_0.8/e107_admin/plugin.php,v $
|
||||
| $Revision: 1.11 $
|
||||
| $Date: 2008-02-01 14:11:27 $
|
||||
| $Revision: 1.12 $
|
||||
| $Date: 2008-02-02 22:04:18 $
|
||||
| $Author: mcfly_e107 $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@ -144,125 +144,108 @@ if ($action == 'uninstall')
|
||||
|
||||
$id = intval($id);
|
||||
$plug = $plugin->getinfo($id);
|
||||
$text = '';
|
||||
//Uninstall Plugin
|
||||
if ($plug['plugin_installflag'] == TRUE )
|
||||
{
|
||||
include(e_PLUGIN.$plug['plugin_path'].'/plugin.php');
|
||||
|
||||
$func = $eplug_folder.'_uninstall';
|
||||
if (function_exists($func))
|
||||
$_path = e_PLUGIN.$plug['plugin_path'].'/';
|
||||
if(file_exists($_path.'plugin.xml'))
|
||||
{
|
||||
$text .= call_user_func($func);
|
||||
}
|
||||
|
||||
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 />";
|
||||
}
|
||||
}
|
||||
$text .= $plugin->manage_plugin_xml($id, 'uninstall');
|
||||
}
|
||||
else
|
||||
{
|
||||
$text .= EPL_ADLAN_49."<br />";
|
||||
}
|
||||
|
||||
if (is_array($eplug_prefs))
|
||||
{
|
||||
$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)
|
||||
include(e_PLUGIN.$plug['plugin_path'].'/plugin.php');
|
||||
|
||||
$func = $eplug_folder.'_uninstall';
|
||||
if (function_exists($func))
|
||||
{
|
||||
$plugin->manage_plugin_prefs('remove', $key, $eplug_folder, $val);
|
||||
$text .= call_user_func($func);
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
if($_POST['delete_tables'])
|
||||
{
|
||||
$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
|
||||
{
|
||||
$tmp = addslashes(serialize($user_entended));
|
||||
$sql->db_Update("core", "e107_value='$tmp' WHERE e107_name='user_entended' ");
|
||||
$text .= EPL_ADLAN_49."<br />";
|
||||
}
|
||||
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)
|
||||
{
|
||||
$sql->db_Delete('menus', "menu_name='$eplug_menu_name' ");
|
||||
}
|
||||
$plugin->manage_search('remove', $eplug_folder);
|
||||
|
||||
if ($eplug_link)
|
||||
{
|
||||
$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);
|
||||
$plugin->manage_notify('remove', $eplug_folder);
|
||||
|
||||
$sql->db_Update('plugin', "plugin_installflag=0, plugin_version='{$eplug_version}' WHERE plugin_id='{$id}' ");
|
||||
if (isset($pref['plug_installed'][$plug['plugin_path']]))
|
||||
@ -270,181 +253,152 @@ if ($action == 'uninstall')
|
||||
unset($pref['plug_installed'][$plug['plugin_path']]);
|
||||
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')
|
||||
{
|
||||
$plugin->install_plugin(intval($id));
|
||||
$text = $plugin->install_plugin($id);
|
||||
$plugin ->save_addon_prefs();
|
||||
// if($eplug_conffile){ $text .= " <a href='".e_PLUGIN."$eplug_folder/$eplug_conffile'>[".LAN_CONFIGURE."]</a>"; }
|
||||
$ns->tablerender(EPL_ADLAN_33, $text);
|
||||
}
|
||||
|
||||
if ($action == 'upgrade')
|
||||
{
|
||||
$plug = $plugin->getinfo($id);
|
||||
include(e_PLUGIN.$plug['plugin_path'].'/plugin.php');
|
||||
|
||||
$func = $eplug_folder.'_upgrade';
|
||||
if (function_exists($func))
|
||||
|
||||
$_path = e_PLUGIN.$plug['plugin_path'].'/';
|
||||
if(file_exists($_path.'plugin.xml'))
|
||||
{
|
||||
$text .= call_user_func($func);
|
||||
}
|
||||
|
||||
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);
|
||||
$text .= $plugin->manage_plugin_xml($id, 'upgrade');
|
||||
}
|
||||
else
|
||||
{
|
||||
$plugin->manage_plugin_prefs('remove', 'modules', $eplug_folder);
|
||||
}
|
||||
|
||||
if ($eplug_status)
|
||||
{
|
||||
$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)
|
||||
include(e_PLUGIN.$plug['plugin_path'].'/plugin.php');
|
||||
|
||||
$func = $eplug_folder.'_upgrade';
|
||||
if (function_exists($func))
|
||||
{
|
||||
$plugin->manage_plugin_prefs('add', $key, $eplug_folder, $val);
|
||||
$text .= call_user_func($func);
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($upgrade_remove_array_pref))
|
||||
{
|
||||
foreach($upgrade_remove_array_pref as $key => $val)
|
||||
|
||||
if (is_array($upgrade_alter_tables))
|
||||
{
|
||||
$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 (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))
|
||||
|
||||
if ($eplug_module)
|
||||
{
|
||||
$user_entended[] = $e_user_pref;
|
||||
}
|
||||
$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' ");
|
||||
$plugin->manage_plugin_prefs('add', 'modules', $eplug_folder);
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql->db_Insert("core", "'user_entended', '$tmp' ");
|
||||
$plugin->manage_plugin_prefs('remove', 'modules', $eplug_folder);
|
||||
}
|
||||
$text .= EPL_ADLAN_8."<br />";
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
if ($eplug_status)
|
||||
{
|
||||
$sql->db_Delete("core", "e107_name='user_entended'");
|
||||
$plugin->manage_plugin_prefs('add', 'plug_status', $eplug_folder);
|
||||
}
|
||||
else
|
||||
{
|
||||
$tmp = addslashes(serialize($user_entended));
|
||||
$sql->db_Update("core", "e107_value='$tmp' WHERE e107_name='user_entended' ");
|
||||
$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);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
$plugin -> save_addon_prefs();
|
||||
$plugin->save_addon_prefs();
|
||||
}
|
||||
|
||||
|
||||
|
@ -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.26 $
|
||||
| $Date: 2008-02-02 03:23:47 $
|
||||
| $Revision: 1.27 $
|
||||
| $Date: 2008-02-02 22:04:18 $
|
||||
| $Author: mcfly_e107 $
|
||||
+----------------------------------------------------------------------------+
|
||||
*/
|
||||
@ -30,16 +30,15 @@ class e107plugin
|
||||
'eplug_prefs',
|
||||
'eplug_array_pref', // missing previously
|
||||
'eplug_table_names',
|
||||
'eplug_user_prefs',
|
||||
'eplug_sc',
|
||||
'eplug_userclass',
|
||||
'eplug_module',
|
||||
'eplug_bb',
|
||||
'eplug_latest',
|
||||
'eplug_status' //,
|
||||
// 'eplug_comment_ids', // Not sure about this one
|
||||
// 'eplug_menu_name', // ...or this one
|
||||
// 'eplug_conffile' // ...or this one
|
||||
'eplug_status',
|
||||
'eplug_comment_ids',
|
||||
'eplug_conffile',
|
||||
'eplug_menu_name'
|
||||
);
|
||||
|
||||
// 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_add_prefs',
|
||||
'upgrade_remove_prefs',
|
||||
'upgrade_add_user_prefs',
|
||||
'upgrade_remove_user_prefs',
|
||||
'upgrade_add_array_pref',
|
||||
'upgrade_remove_array_pref'
|
||||
);
|
||||
@ -69,7 +66,7 @@ class e107plugin
|
||||
var $plug_vars;
|
||||
var $current_plug;
|
||||
var $parsed_plugin;
|
||||
|
||||
|
||||
function e107plugin()
|
||||
{
|
||||
$parsed_plugin = array();
|
||||
@ -385,10 +382,10 @@ class e107plugin
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function manage_comments($action,$comment_id)
|
||||
function manage_comments($action, $comment_id)
|
||||
{
|
||||
global $sql, $tp;
|
||||
$tmp = array();
|
||||
if($action == 'remove')
|
||||
{
|
||||
foreach($comment_id as $com)
|
||||
@ -396,11 +393,11 @@ class e107plugin
|
||||
$tmp[] = "comment_type='".$tp -> toDB($com, true)."'";
|
||||
}
|
||||
$qry = implode(" OR ",$tmp);
|
||||
return $sql->db_Delete('comments',$qry);
|
||||
echo $qry."<br />";
|
||||
return $sql->db_Delete('comments', $qry);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function manage_tables($action, $var)
|
||||
{
|
||||
global $sql;
|
||||
@ -604,10 +601,11 @@ class e107plugin
|
||||
$id = (int)$id;
|
||||
$plug = $this->getinfo($id);
|
||||
$this->current_plug = $plug;
|
||||
$txt = '';
|
||||
$path = e_PLUGIN.$plug['plugin_path'].'/';
|
||||
|
||||
//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.
|
||||
$addons = explode(',', $plug['plugin_addons']);
|
||||
@ -637,7 +635,7 @@ class e107plugin
|
||||
}
|
||||
|
||||
// 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
|
||||
// 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 );
|
||||
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);
|
||||
$tablename = trim($match[1]);
|
||||
echo "Removing table $tablename <br />";
|
||||
$txt .= "Removing table $tablename <br />";
|
||||
$this->manage_tables('remove', array($tablename));
|
||||
}
|
||||
if($function == 'install')
|
||||
{
|
||||
$sql_table = preg_replace("/create table\s+/si", "CREATE TABLE #", $sql_table);
|
||||
echo "Adding table: <pre>{$sql_table}</pre><br />";
|
||||
$this->manage_tables('add', array($sql_table));
|
||||
$sql_table = preg_replace("/create table\s+/si", "CREATE TABLE ".MPREFIX, $sql_table);
|
||||
$txt .= "Adding table: {$tablename} ... ";
|
||||
$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')
|
||||
{
|
||||
$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);
|
||||
}
|
||||
//remove inactive links on upgrade
|
||||
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']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'uninstall':
|
||||
//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']);
|
||||
break;
|
||||
}
|
||||
@ -719,14 +719,14 @@ class e107plugin
|
||||
case 'upgrade':
|
||||
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']);
|
||||
}
|
||||
|
||||
//If upgrading, removing any inactive pref
|
||||
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']);
|
||||
}
|
||||
break;
|
||||
@ -735,7 +735,7 @@ class e107plugin
|
||||
case 'uninstall':
|
||||
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']);
|
||||
}
|
||||
break;
|
||||
@ -745,55 +745,53 @@ class e107plugin
|
||||
|
||||
//Userclasses
|
||||
//$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']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$uclass_list = $plug_vars['userclasses']['userclass'];
|
||||
}
|
||||
foreach($uclass_list as $uclass)
|
||||
{
|
||||
$attrib = $uclass['@attributes'];
|
||||
switch($function)
|
||||
case 'install':
|
||||
case 'upgrade':
|
||||
// Add all active userclasses
|
||||
if(!isset($attrib['active']) || $attrib['active'] == 'true')
|
||||
{
|
||||
case 'install':
|
||||
case 'upgrade':
|
||||
// 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;
|
||||
$txt .= "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')
|
||||
{
|
||||
$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_notify($function, $plug_vars['folder']);
|
||||
$this->manage_search($function, $plug_vars['folder']);
|
||||
$this->manage_notify($function, $plug_vars['folder']);
|
||||
|
||||
// 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')
|
||||
@ -806,12 +804,13 @@ class e107plugin
|
||||
|
||||
if($function == 'install')
|
||||
{
|
||||
$text .= LAN_INSTALL_SUCCESSFUL."<br />";
|
||||
$txt .= LAN_INSTALL_SUCCESSFUL."<br />";
|
||||
if(isset($plug_vars['installDone']))
|
||||
{
|
||||
$text .= $plug_vars['installDone'];
|
||||
$txt .= $plug_vars['installDone'];
|
||||
}
|
||||
}
|
||||
return $txt;
|
||||
}
|
||||
|
||||
function execute_function($path = '', $what='', $when='')
|
||||
@ -935,29 +934,6 @@ class e107plugin
|
||||
$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 != '')
|
||||
{
|
||||
$linkperm = (isset($eplug_link_perms) ? $eplug_link_perms : e_UC_PUBLIC);
|
||||
@ -1019,8 +995,7 @@ class e107plugin
|
||||
{
|
||||
$text = EPL_ADLAN_21;
|
||||
}
|
||||
if($eplug_conffile){ $text .= " <a href='".e_PLUGIN."$eplug_folder/$eplug_conffile'>[".LAN_CONFIGURE."]</a>"; }
|
||||
$ns->tablerender(EPL_ADLAN_33, $text);
|
||||
return $text;
|
||||
}
|
||||
|
||||
function save_addon_prefs()
|
||||
@ -1234,7 +1209,7 @@ class e107plugin
|
||||
include($path.'plugin.php');
|
||||
$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['name'] = varset($eplug_name);
|
||||
|
@ -8,6 +8,8 @@
|
||||
<compatibility>0.8</compatibility>
|
||||
<installRequired>true</installRequired>
|
||||
<folder>forum</folder>
|
||||
<commentID>forum1</commentID>
|
||||
<commentID>forum2</commentID>
|
||||
<administration>
|
||||
<configFile>forum_admin.php</configFile>
|
||||
<icon>images/forums_32.png</icon>
|
||||
@ -35,9 +37,8 @@
|
||||
<key name="pref3" value="val3" />
|
||||
</pref>
|
||||
</mainPrefs>
|
||||
<userclasses>
|
||||
<userclass name="forum_moderator" description="Moderator of all forums" />
|
||||
</userclasses>
|
||||
<userclass name="forum_moderator" description="Moderator of all forums" />
|
||||
<userclass name="forum_moderator2" description="Moderator of all forums" />
|
||||
<management>
|
||||
<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" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user