1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 12:48:24 +01:00

Make calls to plugin handers consistent - always use plugin name (directory name)

This commit is contained in:
e107steved 2008-12-10 22:39:43 +00:00
parent abfc973147
commit a96c38306f
5 changed files with 121 additions and 65 deletions

View File

@ -11,14 +11,15 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_admin/plugin.php,v $
| $Revision: 1.21 $
| $Date: 2008-12-04 21:36:08 $
| $Author: mcfly_e107 $
| $Revision: 1.22 $
| $Date: 2008-12-10 22:39:43 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
*/
require_once("../class2.php");
if (!getperms("Z")) {
if (!getperms("Z"))
{
header("location:".e_BASE."index.php");
exit;
}
@ -32,6 +33,9 @@ $tmp = explode('.', e_QUERY);
$action = $tmp[0];
$id = intval($tmp[1]);
define('PLUGIN_SHOW_REFRESH', FALSE);
if (isset($_POST['upload']))
{
if (!$_POST['ac'] == md5(ADMINPWCHANGE))
@ -249,6 +253,7 @@ if ($action == 'uninstall')
$plugin->manage_notify('remove', $eplug_folder);
}
$admin_log->log_event('PLUGMAN_03', $plug['plugin_path'], E_LOG_INFORMATIVE, '');
if (isset($pref['plug_installed'][$plug['plugin_path']]))
{
@ -274,18 +279,20 @@ if ($action == 'uninstall')
$text = '';
}
if ($action == 'install')
{
$text = $plugin->install_plugin($id);
if ($text === FALSE)
{ // Tidy this up
$ns->tablerender(LAN_INSTALL_FAIL, "Error messages above this line");
$ns->tablerender(LAN_INSTALL_FAIL, "Error messages above this line");
}
else
{
$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);
$admin_log->log_event('PLUGMAN_01', $id.':'.$eplug_folder, E_LOG_INFORMATIVE, '');
$ns->tablerender(EPL_ADLAN_33, $text);
}
}
@ -401,6 +408,7 @@ if ($action == 'upgrade')
$eplug_addons = $plugin -> getAddons($eplug_folder);
$admin_log->log_event('PLUGMAN_02', $eplug_folder, E_LOG_INFORMATIVE, '');
$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
@ -412,6 +420,19 @@ if ($action == 'upgrade')
}
if ($action == 'refresh')
{
$plug = $plugin->getinfo($id);
$_path = e_PLUGIN.$plug['plugin_path'].'/';
if(file_exists($_path.'plugin.xml'))
{
$text .= $plugin->manage_plugin_xml($id, 'refresh');
$admin_log->log_event('PLUGMAN_04', $id.':'.$plug['plugin_path'], E_LOG_INFORMATIVE, '');
}
}
// Check for new plugins, create entry in plugin table ...
$plugin->update_plugins_table();
@ -472,7 +493,8 @@ function render_plugs($pluginList)
{
$_path = e_PLUGIN.$plug['plugin_path'].'/';
$plug_vars = false;
if($plugin->parse_plugin($_path))
// if($plugin->parse_plugin($_path))
if($plugin->parse_plugin($plug['plugin_path']))
{
$plug_vars = $plugin->plug_vars;
}
@ -547,7 +569,18 @@ function render_plugs($pluginList)
if ($plug_vars['@attributes']['installRequired'])
{
$text .= ($plug['plugin_installflag'] ? "<input type='button' class='button' onclick=\"location.href='".e_SELF."?uninstall.{$plug['plugin_id']}'\" title='".EPL_ADLAN_1."' value='".EPL_ADLAN_1."' /> " : "<input type='button' class='button' onclick=\"location.href='".e_SELF."?install.{$plug['plugin_id']}'\" title='".EPL_ADLAN_0."' value='".EPL_ADLAN_0."' />");
if ($plug['plugin_installflag'])
{
$text .= ($plug['plugin_installflag'] ? "<input type='button' class='button' onclick=\"location.href='".e_SELF."?uninstall.{$plug['plugin_id']}'\" title='".EPL_ADLAN_1."' value='".EPL_ADLAN_1."' /> " : "<input type='button' class='button' onclick=\"location.href='".e_SELF."?install.{$plug['plugin_id']}'\" title='".EPL_ADLAN_0."' value='".EPL_ADLAN_0."' />");
if (PLUGIN_SHOW_REFRESH && !varsettrue($plug_vars['plugin_php']))
{
$text .= "<br /><br /><input type='button' class='button' onclick=\"location.href='".e_SELF."?refresh.{$plug['plugin_id']}'\" title='".'Refresh plugin settings'."' value='".'Refresh plugin settings'."' /> ";
}
}
else
{
$text .= "<input type='button' class='button' onclick=\"location.href='".e_SELF."?install.{$plug['plugin_id']}'\" title='".EPL_ADLAN_0."' value='".EPL_ADLAN_0."' />";
}
}
else
{
@ -595,11 +628,11 @@ function show_uninstall_confirm()
global $plugin, $tp, $id, $ns;
$id = intval($id);
$plug = $plugin->getinfo($id);
$_path = e_PLUGIN.$plug['plugin_path'];
// $_path = e_PLUGIN.$plug['plugin_path'];
if ($plug['plugin_installflag'] == true )
{
if($plugin->parse_plugin($_path))
if($plugin->parse_plugin($plug['plugin_path']))
{
$plug_vars = $plugin->plug_vars;
}

View File

@ -1,6 +1,6 @@
/*
* e107 website system (c) 2001-2008 Steve Dunstan (e107.org)
* $Id: admin_alt_nav.sc,v 1.6 2008-12-07 21:41:04 e107steved Exp $
* $Id: admin_alt_nav.sc,v 1.7 2008-12-10 22:39:43 e107steved Exp $
*/
if (ADMIN)
@ -77,8 +77,7 @@ if (ADMIN)
{
if(getperms('P'.$row['plugin_id']))
{
$_path = e_PLUGIN.$row['plugin_path'].'/';
if($plug->parse_plugin($_path))
if($plug->parse_plugin($row['plugin_path']))
{
$plug_vars = $plug->plug_vars;
loadLanFiles($row['plugin_path'], 'admin');

View File

@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/plugin_class.php,v $
| $Revision: 1.57 $
| $Date: 2008-12-10 13:41:36 $
| $Author: mcfly_e107 $
| $Revision: 1.58 $
| $Date: 2008-12-10 22:39:43 $
| $Author: e107steved $
+----------------------------------------------------------------------------+
*/
@ -429,6 +429,7 @@ class e107plugin
break;
case 'update' :
case 'refresh' :
// Only update if $pref doesn't exist
if (!isset($pref[$k])) $pref[$k] = $v;
break;
@ -452,6 +453,7 @@ class e107plugin
{
case 'add' :
case 'update' :
case 'refresh' :
if (!in_array($v,$tmp)) $tmp[] = $v;
break;
case 'remove' :
@ -467,6 +469,7 @@ class e107plugin
$pref[$k][$path] = $v;
break;
case 'update' :
case 'refresh' :
if (!isset($pref[$k][$path])) $pref[$k][$path] = $v;
break;
case 'remove' :
@ -503,7 +506,7 @@ class e107plugin
// Handle table updates - passed an array of actions.
// $var array:
// For 'add' - its a query to create the table
// For 'upgrade' - its a query to modify the table
// For 'upgrade' - its a query to modify the table (not called from the plugin.xml handler)
// For 'remove' - its a table name
// 'upgrade' and 'remove' operate on all language variants of the same table
function manage_tables($action, $var)
@ -707,6 +710,12 @@ class e107plugin
//----------------------------------------------------------
// Install routine for XML file
//----------------------------------------------------------
// $id - the number of the plugin in the DB
// Values for $function:
// 'install'
// 'upgrade'
// 'uninstall'
// 'refresh' - adds things that are missing, but doesn't change any existing settings
function manage_plugin_xml($id, $function='')
{
global $sql, $pref;
@ -738,7 +747,7 @@ class e107plugin
}
if($canContinue && $this->parse_plugin_xml($path))
if($canContinue && $this->parse_plugin_xml($plug['plugin_path']))
{
$plug_vars = $this->plug_vars;
}
@ -834,7 +843,7 @@ class e107plugin
$tableList = $dbHandler->get_table_def('',$path.$sqlFile);
if (!is_array($tableList))
{
$error[] = "Can't read SQL definition: ".$path.$sqlFile;
$error[] = 'Can\'t read SQL definition: '.$path.$sqlFile;
break;
}
// Got the required definition here
@ -852,13 +861,15 @@ class e107plugin
$tmp = $dbHandler->update_table_structure($ct,FALSE,TRUE, $pref['multilanguage']);
if ($tmp === FALSE)
{
$error[] = "Unspecified error updating table: {$ct[1]}";
$error[] = 'Error updating table: '.$ct[1];
}
elseif ($tmp !== TRUE)
{
$error[] = $tmp;
}
break;
case 'refresh' : // Leave things alone
break;
case 'uninstall' :
$txt .= "Removing table {$ct[1]} <br />";
$this->manage_tables('remove', array($ct[1])); // Delete the table
@ -885,29 +896,32 @@ class e107plugin
}
switch($function)
{
case 'upgrade':
case 'install':
// Add any active link
if(!isset($attrib['active']) || $attrib['active'] == 'true')
{
$addlink = e_PLUGIN.$attrib['url'];
$perm = (isset($attrib['perm']) ? $attrib['perm'] : 0);
$txt .= "Adding link {$linkName} with url [{$addlink}] and perm {$perm} <br />";
$this->manage_link('add', $addlink, $linkName, $perm);
}
//remove inactive links on upgrade
if($function == 'upgrade' && isset($attrib['active']) && $attrib['active'] == 'false')
{
case 'upgrade':
case 'install':
// Add any active link
if(!isset($attrib['active']) || $attrib['active'] == 'true')
{
$addlink = e_PLUGIN.$attrib['url'];
$perm = (isset($attrib['perm']) ? $attrib['perm'] : 0);
$txt .= "Adding link {$linkName} with url [{$addlink}] and perm {$perm} <br />";
$this->manage_link('add', $addlink, $linkName, $perm);
}
//remove inactive links on upgrade
if($function == 'upgrade' && isset($attrib['active']) && $attrib['active'] == 'false')
{
$txt .= "Removing link {$linkName} with url [{$attrib['url']}] <br />";
$this->manage_link('remove', $attrib['url'], $linkName);
}
break;
case 'refresh' : // Probably best to leave well alone
break;
case 'uninstall':
//remove all links
$txt .= "Removing link {$linkName} with url [{$attrib['url']}] <br />";
$this->manage_link('remove', $attrib['url'], $linkName);
}
break;
case 'uninstall':
//remove all links
$txt .= "Removing link {$linkName} with url [{$attrib['url']}] <br />";
$this->manage_link('remove', $attrib['url'], $linkName);
break;
break;
}
}
}
@ -929,7 +943,8 @@ class e107plugin
$this->manage_prefs('add', $list['active'], $prefType, $plug['plugin_path'], TRUE);
}
break;
case 'upgrade':
case 'upgrade' :
case 'refresh' : // Add any defined prefs which don't already exist
if(is_array($list['active']))
{
$txt .= "Updating {$prefType} prefs ".print_a($list['active'], true)."<br />";
@ -1040,7 +1055,7 @@ class e107plugin
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 />";
$txt .= 'Removing all plugin comments: ('.implode(', ', $commentArray).')<br />';
$this->manage_comments('remove', $commentArray);
}
@ -1056,6 +1071,7 @@ class e107plugin
{
case 'install' :
case 'upgrade' :
case 'refresh' :
$pref['upgradeCheck'][$plug['plugin_path']]['url'] = $tmp['@attributes']['url'];
$pref['upgradeCheck'][$plug['plugin_path']]['method'] = varset($tmp['@attributes']['method'],'sf_news');
$pref['upgradeCheck'][$plug['plugin_path']]['id'] = varset($tmp['@attributes']['id'],$plug['plugin_path']);
@ -1073,6 +1089,7 @@ class e107plugin
{
case 'install' :
case 'upgrade' :
case 'refresh' :
$pref['logLanguageFile'][$plug['plugin_path']] = $plug_vars['logLanguageFile']['@attributes']['filename'];
break;
case 'uninstall' :
@ -1190,7 +1207,7 @@ class e107plugin
$plug['plug_action'] = 'install';
// $plug_vars = $this->parse_plugin_php($path);
// $plug_vars = $this->parse_plugin_php($plug['plugin_path']);
include_once($_path.'plugin.php');
$func = $eplug_folder.'_install';
@ -1484,34 +1501,34 @@ class e107plugin
// Entry point to read plugin configuration data
function parse_plugin($path, $force=false)
function parse_plugin($plugName, $force=false)
{
if(isset($this->parsed_plugin[$path]) && $force != true)
if(isset($this->parsed_plugin[$plugName]) && $force != true)
{
$this->plug_vars = $this->parsed_plugin[$path];
$this->plug_vars = $this->parsed_plugin[$plugName];
return true;
}
unset($this->parsed_plugin[$path]); // In case forced parsing which fails
if(file_exists($path.'plugin.xml'))
unset($this->parsed_plugin[$plugName]); // In case forced parsing which fails
if(file_exists(e_PLUGIN.$plugName.'/plugin.xml'))
{
$ret = $this->parse_plugin_xml($path);
$ret = $this->parse_plugin_xml($plugName);
}
elseif(file_exists($path.'plugin.php'))
elseif(file_exists(e_PLUGIN.$plugName.'/plugin.php'))
{
$ret = $this->parse_plugin_php($path);
$ret = $this->parse_plugin_php($plugName);
}
if($ret == true)
{
$this->parsed_plugin[$path] = $this->plug_vars;
$this->parsed_plugin[$plugName] = $this->plug_vars;
}
return $ret;
}
// Called to parse the (deprecated) plugin.php file
function parse_plugin_php($path)
function parse_plugin_php($plugName)
{
include($path.'plugin.php');
include(e_PLUGIN.$plugName.'/plugin.php');
$ret = array();
// $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);
@ -1543,16 +1560,16 @@ class e107plugin
// Called to parse the plugin.xml file if it exists
function parse_plugin_xml($path)
function parse_plugin_xml($plugName)
{
global $tp;
loadLanFiles($path, 'admin'); // Look for LAN files on default paths
loadLanFiles($plugName, 'admin'); // Look for LAN files on default paths
require_once(e_HANDLER.'xml_class.php');
$xml = new xmlClass;
$this->plug_vars = $xml->loadXMLfile($path.'plugin.xml', true, true);
$this->plug_vars = $xml->loadXMLfile(e_PLUGIN.$plugName.'/plugin.xml', true, true);
if ($this->plug_vars === FALSE)
{
echo "Error reading {$path}/plugin.xml<br />";
echo "Error reading {$plugName}/plugin.xml<br />";
return FALSE;
}
// print_a($this->plug_vars);

View File

@ -1,6 +1,6 @@
<?php
// e107 Language File.
// $Id: lan_log_messages.php,v 1.34 2008-12-07 14:22:40 e107steved Exp $
// $Id: lan_log_messages.php,v 1.35 2008-12-10 22:39:43 e107steved Exp $
/*
The definitions in this file are for standard 'explanatory' messages which might be entered
@ -210,7 +210,8 @@ define('LAN_AL_BANNER_01','Banner menu update');
define('LAN_AL_BANNER_02','Banner created');
define('LAN_AL_BANNER_03','Banner updated');
define('LAN_AL_BANNER_04','Banner deleted');
define('LAN_AL_BANNER_05','');
define('LAN_AL_BANNER_05','Banner configuration updated');
define('LAN_AL_BANNER_06','');
// Image management
//-----------------
@ -339,5 +340,12 @@ define('LAN_AL_MAIL_05', 'Delete orphaned emails');
define('LAN_AL_MAIL_06', '');
define('LAN_AL_MAIL_07', '');
// Plugin Manager
//---------------
define('LAN_AL_PLUGMAN_01', 'Plugin installed');
define('LAN_AL_PLUGMAN_02', 'Plugin updated');
define('LAN_AL_PLUGMAN_03', 'Plugin uninstalled');
define('LAN_AL_PLUGMAN_04', 'Plugin refreshed');
?>

View File

@ -1,6 +1,6 @@
/*
* e107 website system (c) 2001-2008 Steve Dunstan (e107.org)
* $Id: fs_admin_alt_nav.sc,v 1.2 2008-12-10 16:59:19 secretr Exp $
* $Id: fs_admin_alt_nav.sc,v 1.3 2008-12-10 22:39:43 e107steved Exp $
*/
if (ADMIN)
@ -113,8 +113,7 @@ if (ADMIN)
{
if(getperms('P'.$row['plugin_id']))
{
$_path = e_PLUGIN.$row['plugin_path'].'/';
if($plug->parse_plugin($_path))
if($plug->parse_plugin($row['plugin_path']))
{
$plug_vars = $plug->plug_vars;
loadLanFiles($row['plugin_path'], 'admin');