diff --git a/e107_admin/plugin.php b/e107_admin/plugin.php index e3523ad31..8e5c72345 100644 --- a/e107_admin/plugin.php +++ b/e107_admin/plugin.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/plugin.php,v $ -| $Revision: 1.10 $ -| $Date: 2008-01-27 01:34:59 $ +| $Revision: 1.11 $ +| $Date: 2008-02-01 14:11:27 $ | $Author: mcfly_e107 $ +----------------------------------------------------------------------------+ */ @@ -523,7 +523,8 @@ function render_plugs($pluginList) $img = ""; } - $plugin_icon = $plug_vars['administration']['icon'] ? "" : E_32_CAT_PLUG; + $icon_src = (isset($plug_vars['plugin_php']) ? e_PLUGIN : $_path).$plug_vars['administration']['icon']; + $plugin_icon = $plug_vars['administration']['icon'] ? "" : E_32_CAT_PLUG; if ($plug_vars['administration']['configFile'] && $plug['plugin_installflag'] == true) { diff --git a/e107_files/shortcode/admin_alt_nav.sc b/e107_files/shortcode/admin_alt_nav.sc index 5fe912dc6..3cac8ac42 100644 --- a/e107_files/shortcode/admin_alt_nav.sc +++ b/e107_files/shortcode/admin_alt_nav.sc @@ -60,18 +60,24 @@ if (ADMIN) { $render_plugins = FALSE; include_once(e_HANDLER.'plugin_class.php'); $plug = new e107plugin; - if($sql -> db_Select("plugin", "*", "plugin_installflag=1 ORDER BY plugin_path")){ - while($row = $sql -> db_Fetch()){ - if(getperms('P'.$row['plugin_id'])){ - if($plug->parse_plugin(e_PLUGIN.$row['plugin_path'].'/')) + if($sql -> db_Select("plugin", "*", "plugin_installflag=1 ORDER BY plugin_path")) + { + while($row = $sql -> db_Fetch()) + { + if(getperms('P'.$row['plugin_id'])) + { + $_path = e_PLUGIN.$row['plugin_path'].'/'; + if($plug->parse_plugin($_path)) { $plug_vars = $plug->plug_vars; // print_a($plug_vars); // exit; // include_once(e_PLUGIN.$row['plugin_path']."/plugin.php"); - if($plug_vars['administration']['configFile']){ + if($plug_vars['administration']['configFile']) + { $plug_vars['name'] = $tp->toHTML($plug_vars['name'], FALSE, "defs"); - $plugin_icon = $plug_vars['administration']['iconSmall'] ? "".$plug_vars[" : E_16_PLUGIN; + $icon_src = (isset($plug_vars['plugin_php']) ? e_PLUGIN_ABS : e_PLUGIN_ABS.$row['plugin_path'].'/') .$plug_vars['administration']['iconSmall']; + $plugin_icon = $plug_vars['administration']['iconSmall'] ? "".$plug_vars[" : E_16_PLUGIN; $plugin_array[ucfirst($plug_vars['name'])] = adnav_main($plug_vars['name'], e_PLUGIN.$row['plugin_path']."/".$plug_vars['administration']['configFile'], $plugin_icon); } $render_plugins = TRUE; diff --git a/e107_handlers/plugin_class.php b/e107_handlers/plugin_class.php index 26f60340d..2f118266e 100644 --- a/e107_handlers/plugin_class.php +++ b/e107_handlers/plugin_class.php @@ -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.22 $ -| $Date: 2008-02-01 11:52:27 $ +| $Revision: 1.23 $ +| $Date: 2008-02-01 14:11:27 $ | $Author: mcfly_e107 $ +----------------------------------------------------------------------------+ */ @@ -71,9 +71,9 @@ class e107plugin function e107plugin() { - $parsed_plugin = array(); + $parsed_plugin = array(); } - + /** * Returns an array containing details of all plugins in the plugin table - should normally use e107plugin::update_plugins_table() first to * make sure the table is up to date. (Primarily called from plugin manager to get lists of installed and uninstalled plugins. @@ -230,15 +230,16 @@ class e107plugin */ function getinfo($id, $force=false) { - global $sql, $getinfo_results; + global $sql; + static $getinfo_results; if(!is_array($getinfo_results)) { $getinfo_results = array(); } - + $id = (int)$id; if(!isset($getinfo_results[$id]) || $force == true) { if ($sql->db_Select('plugin', '*', "plugin_id = ".$id)) { - $getinfo_results[$id]; $sql->db_Fetch(); + $getinfo_results[$id] = $sql->db_Fetch(); } else { @@ -598,12 +599,22 @@ class e107plugin function manage_plugin_xml($id, $function='') { + global $sql; $id = (int)$id; $plug = $this->getinfo($id); - $path = e_PLUGIN.$plug['plugin_path'].'/'; + $path = e_PLUGIN.$plug['plugin_path'].'/'; + $addons = explode(',', $plug['plugin_addons']); + $sql_list = array(); + foreach($addons as $addon) + { + if(substr($addon, -4) == '_sql') + { + $sql_list[] = $addon.'.php'; + } + } //Will 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. if(!file_exists($path.'plugin.xml') || $function == '') @@ -621,32 +632,36 @@ class e107plugin { return false; } - - //tables - if(($function == 'install' || $function == 'uninstall') || isset($plug_vars['sqlFile'])) + + // tables + // This will load each _sql.php file found in the plugin directory and parse it. + if(($function == 'install' || $function == 'uninstall') && count($sql_list)) { - if($sql_data = file_get_contents($path.$plug_vars['sqlFile'])) + foreach($sql_list as $sql_file) { - preg_match_all("/create(.*?)myisam.*?;/si", $sql_data, $result ); - foreach ($result[0] as $sql_table) + if($sql_data = file_get_contents($path.$sql_file)) { - if($function == 'uninstall') + preg_match_all("/create(.*?)myisam.*?;/si", $sql_data, $result ); + foreach ($result[0] as $sql_table) { - preg_match("/CREATE TABLE(.*?)\(/si", $sql_table, $match); - $tablename = trim($match[1]); - echo "Removing table $tablename
"; -// $this->manage_tables('remove', array($tablename)); - } - if($function == 'install') - { - $sql_table = preg_replace("/create table\s+/si", "CREATE TABLE #", $sql_table); - echo "Adding table:
{$sql_table}

"; -// $this->manage_tables('add', array($sql_table)); + if($function == 'uninstall') + { + preg_match("/CREATE TABLE(.*?)\(/si", $sql_table, $match); + $tablename = trim($match[1]); + echo "Removing table $tablename
"; + // $this->manage_tables('remove', array($tablename)); + } + if($function == 'install') + { + $sql_table = preg_replace("/create table\s+/si", "CREATE TABLE #", $sql_table); + echo "Adding table:
{$sql_table}

"; + // $this->manage_tables('add', array($sql_table)); + } } } } } - + //main menu items if(isset($plug_vars['menuLink'])) { @@ -662,30 +677,30 @@ class e107plugin { case 'upgrade': case 'install': - // Add any active link - 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}
"; -// 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']}]
"; -// manage_link('remove', $attrib['url'], $attrib['name']); - } - break; + // Add any active link + 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}
"; + // 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']}]
"; + // manage_link('remove', $attrib['url'], $attrib['name']); + } + break; case 'uninstall': - //remove all links - echo "Removing link {$attrib['name']} with url [{$attrib['url']}]
"; -// manage_link('remove', $attrib['url'], $attrib['name']); - break; + //remove all links + echo "Removing link {$attrib['name']} with url [{$attrib['url']}]
"; + // manage_link('remove', $attrib['url'], $attrib['name']); + break; } } } - + //main pref items if(isset($plug_vars['mainPrefs'])) { @@ -699,11 +714,10 @@ class e107plugin { $pref_list = $plug_vars['mainPrefs']['pref']; } - $list = array(); - foreach($pref_list as $pref) + foreach($pref_list as $_pref) { - $attrib = $pref['@attributes']; + $attrib = $_pref['@attributes']; $list['all'][$attrib['name']] = $attrib['value']; if(!isset($attrib['active']) || $attrib['active'] == 'true') { @@ -718,75 +732,81 @@ class e107plugin { case 'install': case 'upgrade': - if(!isset($attrib['active']) || $attrib['active'] == 'true') - { - echo "Adding prefs ".print_a($list['active'], true)."
"; -// manage_prefs('add', $list['active']); - } - - //If upgrading, removing any inactive pref - if($function == 'upgrade') - { - echo "Removing prefs ".print_a($list['inactive'], true)."
"; -// manage_prefs('remove', $list['inactive']); - } - break; - + if(is_array($list['active'])) + { + echo "Adding prefs ".print_a($list['active'], true)."
"; + // 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)."
"; + // manage_prefs('remove', $list['inactive']); + } + break; + //If uninstalling, remove all prefs (active or inactive) case 'uninstall': + if(is_array($list['all'])) + { echo "Removing prefs ".print_a($list['all'], true)."
"; -// manage_prefs('remove', $list['all']); - break; + // manage_prefs('remove', $list['all']); + } + break; } } } - + //Userclasses //$this->manage_userclass('add', $eplug_userclass, $eplug_userclass_description); if(isset($plug_vars['userclasses'])) { - if(isset($plug_vars['userclasses']['userclass'])) { if(!is_array($plug_vars['userclasses']['userclass'])) { - $uclass_list = array($plug_vars['mainPrefs']['pref']); + $uclass_list = array($plug_vars['userclasses']['userclass']); } else { - $uclass_list = $plug_vars['mainPrefs']['pref']; + $uclass_list = $plug_vars['userclasses']['userclass']; } + print_a($uclass_list); + foreach($uclass_list as $uclass) { + print_a($uclass); $attrib = $uclass['@attributes']; switch($function) { case 'install': case 'upgrade': - if(!isset($attrib['active']) || $attrib['active'] == 'true') - { - echo "Adding userclass ".$attrib['name']."
"; -// manage_userclass('add', $attrib['name'], $attrib['description']); - } - - //If upgrading, removing any inactive pref - if($function == 'upgrade' && isset($attrib['active']) && $attrib['active'] == 'false') - { - echo "Removing userclass ".$attrib['name']."
"; -// manage_userclass('remove', $attrib['name'], $attrib['description']); - } - break; - + // Add all active userclasses + if(!isset($attrib['active']) || $attrib['active'] == 'true') + { + echo "Adding userclass ".$attrib['name']."
"; + // 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']."
"; + // manage_userclass('remove', $attrib['name'], $attrib['description']); + } + break; + //If uninstalling, remove all userclasses (active or inactive) case 'uninstall': - echo "Removing prefs ".$attrib['name']."
"; -// manage_userclass('remove', $attrib['name'], $attrib['description']); - break; + echo "Removing prefs ".$attrib['name']."
"; + // manage_userclass('remove', $attrib['name'], $attrib['description']); + break; } } } } - + $this -> manage_search($function, $plug_vars['folder']); $this -> manage_notify($function, $plug_vars['folder']); @@ -807,20 +827,19 @@ class e107plugin $text .= $plug_vars['installDone']; } } - - } + } function install_plugin_php($id) { global $sql; - + $plug = $this->getinfo($id); - $_path = e_PLUGIN.$plug['plugin_path'].'/'; + $_path = e_PLUGIN.$plug['plugin_path'].'/'; $plug['plug_action'] = 'install'; - // $plug_vars = $this->parse_plugin_php($path); + // $plug_vars = $this->parse_plugin_php($path); include_once($path.'plugin.php'); $func = $eplug_folder.'_install'; @@ -935,13 +954,13 @@ class e107plugin $id = (int)$id; $plug = $this->getinfo($id); $plug['plug_action'] = 'install'; - + if ($plug['plugin_installflag'] == FALSE) { $_path = e_PLUGIN.$plug['plugin_path'].'/'; if(file_exists($_path.'plugin.xml')) { - $text = $this->manage_plugin_xml($_path, 'install'); + $text = $this->manage_plugin_xml($id, 'install'); } elseif(file_exists($_path.'plugin.php')) { @@ -1199,9 +1218,10 @@ class e107plugin include_lan($path.'languages/admin/'.e_LANGUAGE.'.php'); require_once(e_HANDLER.'xml_class.php'); $xml = new xmlClass; - $xml->loadXMLfile($path.'plugin.xml', true, true); - $xml->xmlFileContents = $tp->replaceConstants($xml->xmlFileContents, '', true); - $this->plug_vars = $xml->parseXml(); + $this->plug_vars = $xml->loadXMLfile($path.'plugin.xml', true, true); +// $xml->loadXMLfile($path.'plugin.xml', true, true); +// $xml->xmlFileContents = $tp->replaceConstants($xml->xmlFileContents, '', true); +// $this->plug_vars = $xml->parseXml(); return true; } diff --git a/e107_handlers/xml_class.php b/e107_handlers/xml_class.php index 27ef09c4c..59b3eef7d 100644 --- a/e107_handlers/xml_class.php +++ b/e107_handlers/xml_class.php @@ -11,9 +11,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_handlers/xml_class.php,v $ -| $Revision: 1.4 $ -| $Date: 2008-01-30 20:33:16 $ -| $Author: secretr $ +| $Revision: 1.5 $ +| $Date: 2008-02-01 14:11:27 $ +| $Author: mcfly_e107 $ +----------------------------------------------------------------------------+ */ @@ -120,7 +120,7 @@ class xmlClass return $xml; } - function loadXMLfile($fname='', $parse = false) + function loadXMLfile($fname='', $parse = false, $replace_constants = false) { if($fname == '') @@ -142,6 +142,16 @@ class xmlClass } if($this->xmlFileContents) { + if($replace_constants == true) + { + global $tp; + if(!is_object($tp)) + { + require_once('e_parse_class.php'); + $tp = new e_parse; + } + $this->xmlFileContents = $tp->replaceConstants($this->xmlFileContents, '', true); + } if($parse == true) { return $this->parseXML(); diff --git a/e107_plugins/forum/plugin.xml b/e107_plugins/forum/plugin.xml index b22b6dc02..e2328a494 100755 --- a/e107_plugins/forum/plugin.xml +++ b/e107_plugins/forum/plugin.xml @@ -10,11 +10,9 @@ forum forum_admin.php - forum/images/forums_32.png - forum/images/images/forums_16.png + images/forums_32.png + images/images/forums_16.png Configure Forum - true - true Your forum is now installed @@ -35,7 +33,6 @@ - forum_sql.php diff --git a/e107_plugins/pm/plugin.xml b/e107_plugins/pm/plugin.xml index d028cbdc3..22a3654da 100755 --- a/e107_plugins/pm/plugin.xml +++ b/e107_plugins/pm/plugin.xml @@ -10,11 +10,10 @@ pm pm_conf.php - pm/images/pvt_message_32.png - pm/images/pvt_message_16.png + images/pvt_message_32.png + images/pvt_message_16.png {ADLAN_PM_2} - pm_sql.php