mirror of
https://github.com/e107inc/e107.git
synced 2025-04-14 01:22:13 +02:00
Fixed E_NOTICE in plugin install/uninstall process
- FIX: e107::coreLan() now loads the lan_admin.php file if the $admin argument is true - FIX: Variable scope of $eplug_folder in e107plugin::uninstall() - FIX: isset() check order in pluginsTest::makePluginReport() - FIX: class2.php: Missing ADMINPERMS constant in CLI mode
This commit is contained in:
parent
bfad3f7202
commit
62a547aed2
@ -1417,12 +1417,6 @@ define('TIMEOFFSET', $e_deltaTime);
|
||||
// ----------------------------------------------------------------------------
|
||||
$sql->db_Mark_Time('Find/Load Theme');
|
||||
|
||||
if(e_ADMIN_AREA) // Load admin phrases ASAP
|
||||
{
|
||||
e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_admin.php');
|
||||
}
|
||||
|
||||
|
||||
if(!defined('THEME'))
|
||||
{
|
||||
|
||||
@ -2032,6 +2026,7 @@ e107::getDebug()->log("Timezone: ".USERTIMEZONE); // remove later on.
|
||||
define('USERNAME', 'e107-cli');
|
||||
define('USERTHEME', false);
|
||||
define('ADMIN', true);
|
||||
define('ADMINPERMS', false);
|
||||
define('GUEST', false);
|
||||
define('USERCLASS', '');
|
||||
define('USEREMAIL', '');
|
||||
|
@ -3145,6 +3145,11 @@ class e107
|
||||
*/
|
||||
public static function coreLan($fname, $admin = false)
|
||||
{
|
||||
if ($admin)
|
||||
{
|
||||
e107::includeLan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_admin.php');
|
||||
}
|
||||
|
||||
$cstring = 'corelan/'.e_LANGUAGE.'_'.$fname.($admin ? '_admin' : '_front');
|
||||
if(self::getRegistry($cstring)) return;
|
||||
|
||||
|
@ -4311,7 +4311,6 @@ class e107plugin
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function uninstall($id, $options = array())
|
||||
{
|
||||
$pref = e107::getPref();
|
||||
@ -4322,12 +4321,12 @@ class e107plugin
|
||||
$sql = e107::getDb();
|
||||
$plug = e107plugin::getPluginRecord($id);
|
||||
|
||||
$this->log("Uninstalling :".$plug['plugin_path']." with options: ".print_r($options, true));
|
||||
$this->log("Uninstalling :" . $plug['plugin_path'] . " with options: " . print_r($options, true));
|
||||
|
||||
$this->log("e107plugin::getPluginRecord() returned: ".print_r($plug, true));
|
||||
$this->log("e107plugin::getPluginRecord() returned: " . print_r($plug, true));
|
||||
|
||||
// Check if plugin is being used by another plugin before uninstalling it.
|
||||
if(isset($plug['plugin_path']))
|
||||
if (isset($plug['plugin_path']))
|
||||
{
|
||||
if ($this->isUsedByAnotherPlugin($plug['plugin_path']))
|
||||
{
|
||||
@ -4336,146 +4335,145 @@ class e107plugin
|
||||
}
|
||||
}
|
||||
|
||||
$text = '';
|
||||
//Uninstall Plugin
|
||||
if ($plug['plugin_installflag'] == true )
|
||||
$text = '';
|
||||
//Uninstall Plugin
|
||||
$eplug_folder = $plug['plugin_path'];
|
||||
if ($plug['plugin_installflag'] == true)
|
||||
{
|
||||
$this->log("plugin_installflag = true, proceeding to uninstall");
|
||||
|
||||
$_path = e_PLUGIN . $plug['plugin_path'] . '/';
|
||||
|
||||
if (file_exists($_path . 'plugin.xml'))
|
||||
{
|
||||
$this->log("plugin_installflag = true, proceeding to uninstall");
|
||||
unset($_POST['uninstall_confirm']);
|
||||
$this->install_plugin_xml($plug, 'uninstall', $options); //$_POST must be used.
|
||||
}
|
||||
else
|
||||
{ // Deprecated - plugin uses plugin.php
|
||||
$eplug_table_names = null;
|
||||
$eplug_prefs = null;
|
||||
$eplug_comment_ids = null;
|
||||
$eplug_array_pref = null;
|
||||
$eplug_menu_name = null;
|
||||
$eplug_link = null;
|
||||
$eplug_link_url = null;
|
||||
$eplug_link_name = null;
|
||||
$eplug_userclass = null;
|
||||
$eplug_version = null;
|
||||
|
||||
$eplug_folder = $plug['plugin_path'];
|
||||
$_path = e_PLUGIN.$plug['plugin_path'].'/';
|
||||
include(e_PLUGIN . $plug['plugin_path'] . '/plugin.php');
|
||||
|
||||
if(file_exists($_path.'plugin.xml'))
|
||||
$func = $eplug_folder . '_uninstall';
|
||||
if (function_exists($func))
|
||||
{
|
||||
unset($_POST['uninstall_confirm']);
|
||||
$this->install_plugin_xml($plug, 'uninstall', $options); //$_POST must be used.
|
||||
$text .= call_user_func($func);
|
||||
}
|
||||
|
||||
if (!empty($options['delete_tables']))
|
||||
{
|
||||
|
||||
if (is_array($eplug_table_names))
|
||||
{
|
||||
$result = $this->manage_tables('remove', $eplug_table_names);
|
||||
if ($result !== TRUE)
|
||||
{
|
||||
$text .= EPL_ADLAN_27 . ' <b>' . MPREFIX . $result . '</b> - ' . EPL_ADLAN_30 . '<br />';
|
||||
$this->log("Unable to delete table."); // No LANS
|
||||
}
|
||||
else
|
||||
{
|
||||
$text .= EPL_ADLAN_28 . "<br />";
|
||||
$this->log("Deleting tables."); // NO LANS
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{ // Deprecated - plugin uses plugin.php
|
||||
$eplug_table_names = null;
|
||||
$eplug_prefs = null;
|
||||
$eplug_comment_ids= null;
|
||||
$eplug_array_pref= null;
|
||||
$eplug_menu_name = null;
|
||||
$eplug_link = null;
|
||||
$eplug_link_url = null;
|
||||
$eplug_link_name = null;
|
||||
$eplug_userclass = null;
|
||||
$eplug_version = null;
|
||||
|
||||
include(e_PLUGIN.$plug['plugin_path'].'/plugin.php');
|
||||
|
||||
$func = $eplug_folder.'_uninstall';
|
||||
if (function_exists($func))
|
||||
{
|
||||
$text .= call_user_func($func);
|
||||
}
|
||||
|
||||
if(!empty($options['delete_tables']))
|
||||
{
|
||||
|
||||
if (is_array($eplug_table_names))
|
||||
{
|
||||
$result = $this->manage_tables('remove', $eplug_table_names);
|
||||
if ($result !== TRUE)
|
||||
{
|
||||
$text .= EPL_ADLAN_27.' <b>'.MPREFIX.$result.'</b> - '.EPL_ADLAN_30.'<br />';
|
||||
$this->log("Unable to delete table."); // No LANS
|
||||
}
|
||||
else
|
||||
{
|
||||
$text .= EPL_ADLAN_28."<br />";
|
||||
$this->log("Deleting tables."); // NO LANS
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$text .= EPL_ADLAN_49."<br />";
|
||||
$this->log("Tables left intact by request."); // No LANS
|
||||
}
|
||||
|
||||
if (is_array($eplug_prefs))
|
||||
{
|
||||
$this->manage_prefs('remove', $eplug_prefs);
|
||||
$text .= EPL_ADLAN_29."<br />";
|
||||
}
|
||||
|
||||
if (is_array($eplug_comment_ids))
|
||||
{
|
||||
$text .= ($this->manage_comments('remove', $eplug_comment_ids)) ? EPL_ADLAN_50."<br />" : "";
|
||||
}
|
||||
|
||||
if (is_array($eplug_array_pref))
|
||||
{
|
||||
foreach($eplug_array_pref as $key => $val)
|
||||
{
|
||||
$this->manage_plugin_prefs('remove', $key, $eplug_folder, $val);
|
||||
}
|
||||
}
|
||||
/*
|
||||
if ($eplug_menu_name)
|
||||
{
|
||||
$sql->delete('menus', "menu_name='{$eplug_menu_name}' ");
|
||||
}*/
|
||||
$folderFiles = scandir(e_PLUGIN.$plug['plugin_path']);
|
||||
$this->XmlMenus($eplug_folder,'uninstall',$folderFiles);
|
||||
|
||||
if ($eplug_link)
|
||||
{
|
||||
$this->manage_link('remove', $eplug_link_url, $eplug_link_name);
|
||||
}
|
||||
|
||||
if ($eplug_userclass)
|
||||
{
|
||||
$this->manage_userclass('remove', $eplug_userclass);
|
||||
}
|
||||
|
||||
$sql->update('plugin', "plugin_installflag=0, plugin_version='{$eplug_version}' WHERE plugin_path='{$eplug_folder}' ");
|
||||
$this->manage_search('remove', $eplug_folder);
|
||||
|
||||
$this->manage_notify('remove', $eplug_folder);
|
||||
|
||||
// it's done inside install_plugin_xml(), required only here
|
||||
if (isset($pref['plug_installed'][$plug['plugin_path']]))
|
||||
{
|
||||
unset($pref['plug_installed'][$plug['plugin_path']]);
|
||||
}
|
||||
e107::getConfig('core')->setPref($pref);
|
||||
$this->rebuildUrlConfig();
|
||||
e107::getConfig('core')->save(false,true,false);
|
||||
}
|
||||
|
||||
$logInfo = deftrue($plug['plugin_name'],$plug['plugin_name']). " v".$plug['plugin_version']." ({e_PLUGIN}".$plug['plugin_path'].")";
|
||||
e107::getLog()->add('PLUGMAN_03', $logInfo, E_LOG_INFORMATIVE, '');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->log("plugin_installflag = false, uninstall skipped.");
|
||||
}
|
||||
|
||||
if(!empty($options['delete_files']) && ($plug['plugin_installflag'] == true))
|
||||
{
|
||||
if(!empty($eplug_folder))
|
||||
{
|
||||
$result = e107::getFile()->rmtree(e_PLUGIN.$eplug_folder);
|
||||
e107::getDb()->delete('plugin', "plugin_path='".$eplug_folder."'");
|
||||
$text .= ($result ? '<br />'.EPL_ADLAN_86.e_PLUGIN.$eplug_folder : '<br />'.EPL_ADLAN_87.'<br />'.EPL_ADLAN_31.' <b>'.e_PLUGIN.$eplug_folder.'</b> '.EPL_ADLAN_32);
|
||||
$text .= EPL_ADLAN_49 . "<br />";
|
||||
$this->log("Tables left intact by request."); // No LANS
|
||||
}
|
||||
|
||||
if (is_array($eplug_prefs))
|
||||
{
|
||||
$this->manage_prefs('remove', $eplug_prefs);
|
||||
$text .= EPL_ADLAN_29 . "<br />";
|
||||
}
|
||||
|
||||
if (is_array($eplug_comment_ids))
|
||||
{
|
||||
$text .= ($this->manage_comments('remove', $eplug_comment_ids)) ? EPL_ADLAN_50 . "<br />" : "";
|
||||
}
|
||||
|
||||
if (is_array($eplug_array_pref))
|
||||
{
|
||||
foreach ($eplug_array_pref as $key => $val)
|
||||
{
|
||||
$this->manage_plugin_prefs('remove', $key, $eplug_folder, $val);
|
||||
}
|
||||
}
|
||||
/*
|
||||
if ($eplug_menu_name)
|
||||
{
|
||||
$sql->delete('menus', "menu_name='{$eplug_menu_name}' ");
|
||||
}*/
|
||||
$folderFiles = scandir(e_PLUGIN . $plug['plugin_path']);
|
||||
$this->XmlMenus($eplug_folder, 'uninstall', $folderFiles);
|
||||
|
||||
if ($eplug_link)
|
||||
{
|
||||
$this->manage_link('remove', $eplug_link_url, $eplug_link_name);
|
||||
}
|
||||
|
||||
if ($eplug_userclass)
|
||||
{
|
||||
$this->manage_userclass('remove', $eplug_userclass);
|
||||
}
|
||||
|
||||
$sql->update('plugin', "plugin_installflag=0, plugin_version='{$eplug_version}' WHERE plugin_path='{$eplug_folder}' ");
|
||||
$this->manage_search('remove', $eplug_folder);
|
||||
|
||||
$this->manage_notify('remove', $eplug_folder);
|
||||
|
||||
// it's done inside install_plugin_xml(), required only here
|
||||
if (isset($pref['plug_installed'][$plug['plugin_path']]))
|
||||
{
|
||||
unset($pref['plug_installed'][$plug['plugin_path']]);
|
||||
}
|
||||
e107::getConfig('core')->setPref($pref);
|
||||
$this->rebuildUrlConfig();
|
||||
e107::getConfig('core')->save(false, true, false);
|
||||
}
|
||||
else
|
||||
|
||||
$logInfo = deftrue($plug['plugin_name'], $plug['plugin_name']) . " v" . $plug['plugin_version'] . " ({e_PLUGIN}" . $plug['plugin_path'] . ")";
|
||||
e107::getLog()->add('PLUGMAN_03', $logInfo, E_LOG_INFORMATIVE, '');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->log("plugin_installflag = false, uninstall skipped.");
|
||||
}
|
||||
|
||||
if (!empty($options['delete_files']) && ($plug['plugin_installflag'] == true))
|
||||
{
|
||||
if (!empty($eplug_folder))
|
||||
{
|
||||
$text .= '<br />'.EPL_ADLAN_31.' <b>'.e_PLUGIN.$eplug_folder.'</b> '.EPL_ADLAN_32;
|
||||
$result = e107::getFile()->rmtree(e_PLUGIN . $eplug_folder);
|
||||
e107::getDb()->delete('plugin', "plugin_path='" . $eplug_folder . "'");
|
||||
$text .= ($result ? '<br />' . EPL_ADLAN_86 . e_PLUGIN . $eplug_folder : '<br />' . EPL_ADLAN_87 . '<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;
|
||||
}
|
||||
|
||||
e107::getPlug()->clearCache()->buildAddonPrefLists();
|
||||
|
||||
// $this->save_addon_prefs('update');
|
||||
// $this->save_addon_prefs('update');
|
||||
|
||||
$this->log("Uninstall completed");
|
||||
|
||||
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
@ -42,10 +42,10 @@
|
||||
$debug_text .= "---- Pref: plug_installed (version)\n\n";
|
||||
$pref = e107::getConfig('core',true,true)->get('plug_installed');
|
||||
|
||||
$debug_text .= print_r($pref[$pluginDir],true);
|
||||
|
||||
$installedPref = isset($pref[$pluginDir]) ? $pref[$pluginDir] : false;
|
||||
|
||||
$debug_text .= print_r($installedPref,true);
|
||||
|
||||
$debug_text .= "\n\n---- Plugin Prefs: \n\n";
|
||||
$pluginPref = e107::pref($pluginDir);
|
||||
$debug_text .= print_r($pluginPref,true);
|
||||
|
Loading…
x
Reference in New Issue
Block a user