mirror of
https://github.com/e107inc/e107.git
synced 2025-07-31 20:00:37 +02:00
Issue #67 - fix admin log handling of plugin-specific event titles (with language support).
This commit is contained in:
@@ -57,8 +57,8 @@ if(is_array($pref['lan_log_list'])) //... and for any plugins which support it
|
||||
$file = str_replace('--LAN--', e_LANGUAGE, $file);
|
||||
|
||||
// echo "orig = ".$file." ";
|
||||
e107::lan($path,'log',true);
|
||||
//include_lan(e_PLUGIN.$path.'/'.$file);
|
||||
//e107::lan($path,'log',true);
|
||||
include_lan(e_PLUGIN.$path.'/languages/'.$file);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -196,7 +196,7 @@ class system_tools
|
||||
|
||||
if(isset($_POST['plugin_scan']) || e_QUERY == "plugin" || isset($_POST['delplug']) || $_GET['mode']=='plugin_scan')
|
||||
{
|
||||
$this->plugin_viewscan();
|
||||
$this->plugin_viewscan('refresh');
|
||||
}
|
||||
|
||||
if(vartrue($_POST['perform_utf8_convert']))
|
||||
@@ -843,7 +843,7 @@ class system_tools
|
||||
* Plugin Folder Scanner
|
||||
* @return none
|
||||
*/
|
||||
private function plugin_viewscan()
|
||||
private function plugin_viewscan($mode = 'update')
|
||||
{
|
||||
$error_messages = array(0 => DBLAN_31, 1 => DBLAN_32, 2 => DBLAN_33, 3 => DBLAN_34);
|
||||
$error_image = array("integrity_pass.png", "integrity_fail.png", "warning.png", "blank.png");
|
||||
@@ -858,8 +858,8 @@ class system_tools
|
||||
|
||||
require_once (e_HANDLER."plugin_class.php");
|
||||
$ep = new e107plugin();
|
||||
$ep->update_plugins_table(); // scan for e_xxx changes and save to plugin table.
|
||||
$ep->save_addon_prefs(); // generate global e_xxx_list prefs from plugin table.
|
||||
$ep->update_plugins_table($mode); // scan for e_xxx changes and save to plugin table.
|
||||
$ep->save_addon_prefs($mode); // generate global e_xxx_list prefs from plugin table.
|
||||
|
||||
/* we all are awaiting for PHP5 only support - method chaining...
|
||||
$mes->add(DBLAN_22.' - '.DBLAN_23, E_MESSAGE_SUCCESS)
|
||||
|
@@ -66,7 +66,7 @@ if(e_AJAX_REQUEST && isset($_GET['src'])) // Ajax
|
||||
$dir = basename($unarc[0]['filename']);
|
||||
$plugPath = preg_replace("/[^a-z0-9-\._]/", "-", strtolower($dir));
|
||||
|
||||
e107::getSingleton('e107plugin')->update_plugins_table();
|
||||
e107::getSingleton('e107plugin')->update_plugins_table('update');
|
||||
e107::getDb()->db_Select_gen("SELECT plugin_id FROM #plugin WHERE plugin_path = '".$plugPath."' LIMIT 1");
|
||||
$row = e107::getDb()->db_Fetch(MYSQL_ASSOC);
|
||||
$status = e107::getSingleton('e107plugin')->install_plugin($row['plugin_id']);
|
||||
@@ -528,7 +528,7 @@ class pluginManager{
|
||||
$text .= '<br />'.EPL_ADLAN_31.' <b>'.e_PLUGIN.$eplug_folder.'</b> '.EPL_ADLAN_32;
|
||||
}
|
||||
|
||||
$plugin->save_addon_prefs();
|
||||
$plugin->save_addon_prefs('update');
|
||||
|
||||
$this->show_message($text, E_MESSAGE_SUCCESS);
|
||||
// $ns->tablerender(EPL_ADLAN_1.' '.$tp->toHtml($plug['plugin_name'], "", "defs,emotes_off,no_make_clickable"), $text);
|
||||
@@ -651,7 +651,7 @@ class pluginManager{
|
||||
}
|
||||
else
|
||||
{
|
||||
$plugin ->save_addon_prefs();
|
||||
$plugin ->save_addon_prefs('update');
|
||||
$admin_log->log_event('PLUGMAN_01', $this->id.':'.$eplug_folder, E_LOG_INFORMATIVE, '');
|
||||
$this->show_message($text, E_MESSAGE_SUCCESS);
|
||||
}
|
||||
@@ -745,7 +745,7 @@ class pluginManager{
|
||||
|
||||
|
||||
$emessage->add($text, E_MESSAGE_SUCCESS);
|
||||
$plugin->save_addon_prefs();
|
||||
$plugin->save_addon_prefs('update');
|
||||
|
||||
}
|
||||
|
||||
@@ -773,7 +773,7 @@ class pluginManager{
|
||||
function pluginCheck()
|
||||
{
|
||||
global $plugin;
|
||||
$plugin->update_plugins_table();
|
||||
$plugin->update_plugins_table('update');
|
||||
}
|
||||
// ----------------------------------------------------------
|
||||
// render plugin information ...
|
||||
|
@@ -1066,7 +1066,7 @@ function update_706_to_800($type='')
|
||||
if ($just_check) return update_needed('Update plugin table');
|
||||
require_once(e_HANDLER.'plugin_class.php');
|
||||
$ep = new e107plugin;
|
||||
$ep -> update_plugins_table();
|
||||
$ep -> update_plugins_table('update');
|
||||
// $_pdateMessages[] = LAN_UPDATE_XX24;
|
||||
// catch_error($sql);
|
||||
}
|
||||
@@ -1435,8 +1435,8 @@ function update_70x_to_706($type='')
|
||||
// update new fields
|
||||
require_once(e_HANDLER."plugin_class.php");
|
||||
$ep = new e107plugin;
|
||||
$ep->update_plugins_table();
|
||||
$ep->save_addon_prefs();
|
||||
$ep->update_plugins_table('update');
|
||||
$ep->save_addon_prefs('update');
|
||||
}
|
||||
|
||||
if (!isset($pref['displayname_maxlength']))
|
||||
|
@@ -211,10 +211,18 @@ class e107plugin
|
||||
return count($needed) ? $needed : FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Check for new plugins, create entry in plugin table and remove deleted plugins
|
||||
*
|
||||
* @param string $mode = install|upgrade|refresh|uninstall - defines the intent of the call
|
||||
*
|
||||
* 'upgrade' and 'refresh' are very similar in intent, and often take the same actions:
|
||||
* 'upgrade' signals a possible change to the installed list of plugins
|
||||
* 'refresh' validates the stored data for existing plugins, recreating any that has gone missing
|
||||
*/
|
||||
function update_plugins_table()
|
||||
function update_plugins_table($mode = 'upgrade')
|
||||
{
|
||||
|
||||
$sql = e107::getDb();
|
||||
@@ -300,7 +308,10 @@ class e107plugin
|
||||
$this->XmlLanguageFiles('upgrade');
|
||||
}
|
||||
|
||||
|
||||
if ($mode == 'refresh')
|
||||
{
|
||||
if ($this->XmlLanguageFileCheck('_log', 'lan_log_list', 'refresh', $pluginDBList[$plugin_path]['plugin_installflag'], $plugin_path)) $sp = TRUE;
|
||||
}
|
||||
|
||||
// Check for missing plugin_category in plugin table.
|
||||
if ($pluginDBList[$plugin_path]['plugin_category'] == '' || $pluginDBList[$plugin_path]['plugin_category'] != $plug_info['category'])
|
||||
@@ -527,7 +538,7 @@ class e107plugin
|
||||
}
|
||||
|
||||
/**
|
||||
* Field atributes ($field_attrib array) as they have to be defined in plugin.xml:
|
||||
* Field attributes ($field_attrib array) as they have to be defined in plugin.xml:
|
||||
* name - REQUIRED string
|
||||
* text - (string|constant name) field label
|
||||
* type - REQUIRED (constant name) see EUF_* constants in e107_user_extended class
|
||||
@@ -545,6 +556,7 @@ class e107plugin
|
||||
* @param string $field_name normalized field name (see self::ue_field_name())
|
||||
* @param array $field_attrib
|
||||
* @param string $field_source used for system user fields
|
||||
*
|
||||
* @return boolean success
|
||||
*/
|
||||
function manage_extended_field($action, $field_name, $field_attrib, $field_source = '')
|
||||
@@ -882,7 +894,8 @@ class e107plugin
|
||||
$pref[$k] = $v;
|
||||
break;
|
||||
|
||||
case 'update':
|
||||
case 'update' :
|
||||
case 'upgrade' :
|
||||
case 'refresh':
|
||||
// Only update if $pref doesn't exist
|
||||
if (!isset($pref[$k]))
|
||||
@@ -908,7 +921,8 @@ class e107plugin
|
||||
switch ($action)
|
||||
{
|
||||
case 'add':
|
||||
case 'update':
|
||||
case 'update' :
|
||||
case 'upgrade' :
|
||||
case 'refresh':
|
||||
if (!in_array($v, $tmp))
|
||||
$tmp[] = $v;
|
||||
@@ -926,7 +940,8 @@ class e107plugin
|
||||
case 'add':
|
||||
$pref[$k][$path] = $v;
|
||||
break;
|
||||
case 'update':
|
||||
case 'update' :
|
||||
case 'upgrade' :
|
||||
case 'refresh':
|
||||
if (!isset($pref[$k][$path]))
|
||||
$pref[$k][$path] = $v;
|
||||
@@ -1295,7 +1310,7 @@ class e107plugin
|
||||
$canContinue = FALSE;
|
||||
}
|
||||
|
||||
// Load install longuage file and set lan_global pref.
|
||||
// Load install language file and set lan_global pref.
|
||||
$this->XmlLanguageFiles($function, $plug_vars['languageFiles'], 'pre'); // First of all, see if there's a language file specific to install
|
||||
|
||||
// Next most important, if installing or upgrading, check that any dependencies are met
|
||||
@@ -1569,10 +1584,79 @@ class e107plugin
|
||||
return $canContinue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Process XML Tag <LanguageFiles> // DEPRECATED - using _install _log and _global
|
||||
* @param object $function
|
||||
* @param object $tag
|
||||
* Look for a language file in the two acceptable places.
|
||||
* If found, update the appropriate pref
|
||||
*
|
||||
* @param string $fileEnd - the suffix of the file name (e.g. '_global')
|
||||
* @param string $prefName - the name of the pref to be updated
|
||||
* @param string $when = install|upgrade|refresh|uninstall ('update' also supported as alias for 'upgrade')
|
||||
* @param string $isInstalled - flag indicates whether plugin installed
|
||||
* - if false, any preference is removed.
|
||||
* - if TRUE, any preference is added
|
||||
* - so set TRUE to add value to pref regardless
|
||||
* @param string $plugin - name of plugin folder. If empty string, $this->plugFolder is used.
|
||||
*
|
||||
* @return boolean TRUE if pref changed
|
||||
*/
|
||||
public function XmlLanguageFileCheck($fileEnd, $prefName, $when, $isInstalled, $plugin = '')
|
||||
{
|
||||
$core = e107::getConfig('core');
|
||||
|
||||
if (trim($plugin) == '') $plugin = $this->plugFolder;
|
||||
if (!$isInstalled) $when = 'uninstall';
|
||||
|
||||
$updated = false;
|
||||
|
||||
$path_a = e_PLUGIN.$plugin.'/languages/English'.$fileEnd.'.php'; // always check for English so we have a fall-back
|
||||
$path_b = e_PLUGIN.$plugin.'/languages/English/English'.$fileEnd.'.php';
|
||||
$pathEntry = '';
|
||||
|
||||
if (file_exists($path_a))
|
||||
{
|
||||
$pathEntry = '--LAN--'.$fileEnd.'.php';
|
||||
}
|
||||
elseif (file_exists($path_b))
|
||||
{
|
||||
$pathEntry = '--LAN--/--LAN--'.$fileEnd.'.php';
|
||||
}
|
||||
|
||||
$currentPref = $core->getPref($prefName.'/'.$plugin);
|
||||
echo 'Path: '.$plugin.' Current: '.$currentPref.' New: '.$pathEntry.'<br />';
|
||||
switch ($when)
|
||||
{
|
||||
case 'install':
|
||||
case 'upgrade':
|
||||
case 'update' :
|
||||
case 'refresh':
|
||||
if ($currentPref != $pathEntry)
|
||||
{
|
||||
e107::getMessage()->addDebug('Adding '.$plugin.' to '.$prefName);
|
||||
$core->setPref($prefName.'/'.$plugin, $pathEntry);
|
||||
$updated = true;
|
||||
}
|
||||
break;
|
||||
case 'uninstall':
|
||||
if ($currentPref)
|
||||
{
|
||||
e107::getMessage()->addDebug('Removing '.$plugin.' from '.$prefName);
|
||||
$core->removePref($prefName.'/'.$plugin);
|
||||
$updated = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $updated;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Process XML Tag <LanguageFiles> // Tag is DEPRECATED - using _install _log and _global
|
||||
* @param object $function - should $when have been used?
|
||||
* @param object $tag (not used?)
|
||||
* @param string $when = install|upgrade|refresh|uninstall
|
||||
* @return none
|
||||
*/
|
||||
function XmlLanguageFiles($function, $tag='', $when = '')
|
||||
@@ -2259,7 +2343,17 @@ class e107plugin
|
||||
return $text;
|
||||
}
|
||||
|
||||
function save_addon_prefs() // scan the plugin table and create path-array-prefs for each addon.
|
||||
|
||||
/*
|
||||
* scan the plugin table and create path-array-prefs for each addon.
|
||||
*
|
||||
* @param string $mode = install|upgrade|refresh|uninstall - defines the intent of the call
|
||||
*
|
||||
* 'upgrade' and 'refresh' are very similar in intent, and often take the same actions:
|
||||
* 'upgrade' signals a possible change to the installed list of plugins - usually an upgrade
|
||||
* 'refresh' validates the stored data for existing plugins, recreating any that has gone missing
|
||||
*/
|
||||
function save_addon_prefs($mode = 'upgrade')
|
||||
{
|
||||
$sql = e107::getDb();
|
||||
$core = e107::getConfig('core');
|
||||
|
@@ -1326,7 +1326,7 @@ class e_install
|
||||
|
||||
//Create default plugin-table entries.
|
||||
// e107::getConfig('core')->clearPrefCache();
|
||||
e107::getPlugin()->update_plugins_table();
|
||||
e107::getPlugin()->update_plugins_table('update');
|
||||
$this->logLine('Plugins table updated');
|
||||
|
||||
// Install Theme-required plugins
|
||||
@@ -1345,7 +1345,7 @@ class e_install
|
||||
}
|
||||
}
|
||||
|
||||
e107::getSingleton('e107plugin')->save_addon_prefs(); // save plugin addon pref-lists. eg. e_latest_list.
|
||||
e107::getSingleton('e107plugin')->save_addon_prefs('update'); // save plugin addon pref-lists. eg. e_latest_list.
|
||||
$this->logLine('Addon prefs saved');
|
||||
|
||||
$tm = e107::getSingleton('themeHandler');
|
||||
|
Reference in New Issue
Block a user