1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 06:07:32 +02:00

Handle removal of plugins with multiple menus

This commit is contained in:
e107steved
2007-02-10 13:36:27 +00:00
parent 6696526a4a
commit b1c6195382

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/menus.php,v $ | $Source: /cvs_backup/e107_0.8/e107_admin/menus.php,v $
| $Revision: 1.2 $ | $Revision: 1.3 $
| $Date: 2007-02-04 22:00:00 $ | $Date: 2007-02-10 13:36:20 $
| $Author: e107steved $ | $Author: e107steved $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@@ -118,12 +118,17 @@ if($_POST['menuActivate'])
} }
// ============= // =============
foreach ($_POST['menuAct'] as $k => $v) { if (isset($_POST['menuAct']))
if (trim($v)) { {
foreach ($_POST['menuAct'] as $k => $v)
{
if (trim($v))
{
$id = $k; $id = $k;
list($menu_act, $location, $position, $newloc) = explode(".", $_POST['menuAct'][$k]); list($menu_act, $location, $position, $newloc) = explode(".", $_POST['menuAct'][$k]);
} }
} }
}
if ($menu_act == 'config') { if ($menu_act == 'config') {
if($newloc) if($newloc)
@@ -224,29 +229,40 @@ if ($menu_act == "inc") {
} }
if (strpos(e_QUERY, 'configure') === FALSE) if (strpos(e_QUERY, 'configure') === FALSE)
{ { // Scan plugin directories to see if menus to add
$efile = new e_file; $efile = new e_file;
$fileList = $efile->get_files(e_PLUGIN,"_menu\.php$",'standard',2); $fileList = $efile->get_files(e_PLUGIN,"_menu\.php$",'standard',2);
foreach($fileList as $file) { foreach($fileList as $file)
{
list($parent_dir) = explode('/',str_replace(e_PLUGIN,"",$file['path'])); list($parent_dir) = explode('/',str_replace(e_PLUGIN,"",$file['path']));
$file['path'] = str_replace(e_PLUGIN,"",$file['path']); $file['path'] = str_replace(e_PLUGIN,"",$file['path']);
$file['fname'] = str_replace(".php","",$file['fname']); $file['fname'] = str_replace(".php","",$file['fname']);
if (!$sql->db_Count("menus", "(*)", "WHERE menu_name='{$file['fname']}'")) { $valid_menu = FALSE;
if (file_exists(e_PLUGIN.$parent_dir."/plugin.php")) { $existing_menu = $sql->db_Count("menus", "(*)", "WHERE menu_name='{$file['fname']}'");
if (file_exists(e_PLUGIN.$parent_dir."/plugin.php"))
{
include(e_PLUGIN.$parent_dir."/plugin.php"); include(e_PLUGIN.$parent_dir."/plugin.php");
if ($sql->db_Select("plugin", "*", "plugin_path='".$eplug_folder."' AND plugin_installflag='1' ")) { if ($sql->db_Select("plugin", "*", "plugin_path='".$eplug_folder."' AND plugin_installflag='1' "))
$sql->db_Insert("menus", " 0, '{$file['fname']}', 0, 0, 0, '' ,'{$file['path']}'"); { // Its a 'new style' plugin with a plugin.php file - ionly include if plugin installed
$message .= "<b>".MENLAN_10." - ".$file['fname']."</b><br />"; $valid_menu = TRUE; // Whether new or existing, include in list
}
} else {
$sql->db_Insert("menus", " 0, '{$file['fname']}', 0, 0, 0, '' ,'{$file['path']}'");
$message .= "<b>".MENLAN_10." - ".$file['fname']."</b><br />";
} }
} }
else
{ // Just add the menu anyway
$valid_menu = TRUE;
}
if ($valid_menu)
{
$menustr .= "&".str_replace(".php", "", $file['fname']); $menustr .= "&".str_replace(".php", "", $file['fname']);
if (!$existing_menu)
{ // New menu to add to list
$sql->db_Insert("menus", " 0, '{$file['fname']}', 0, 0, 0, '' ,'{$file['path']}'");
$message .= "<b>".MENLAN_10." - ".$file['fname']."</b><br />";
}
}
} }
$sql2 = new db; if (!is_object($sql2)) $sql2 = new db; // Shouldn't be needed
foreach ($menu_areas as $menu_act) { foreach ($menu_areas as $menu_act) {
if ($sql->db_Select("menus", "*", "menu_location='$menu_act' ORDER BY menu_order ASC")) { if ($sql->db_Select("menus", "*", "menu_location='$menu_act' ORDER BY menu_order ASC")) {
$c = 1; $c = 1;