1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 12:48:26 +02:00

URL condig rebuild routine on various places,

Import prefs fix - arrays wasn't imported,
Mislogic of some preference handler methods
This commit is contained in:
secretr
2012-01-06 09:49:08 +00:00
parent b701180324
commit 34b40eddfb
6 changed files with 283 additions and 266 deletions

View File

@@ -52,6 +52,7 @@ $pman->pluginObserver();
require_once("footer.php"); require_once("footer.php");
exit; exit;
// FIXME switch to admin UI
class pluginManager{ class pluginManager{
var $plugArray; var $plugArray;
@@ -193,10 +194,14 @@ class pluginManager{
} }
// FIXME - move it to plugin handler, similar to install_plugin() routine
function pluginUninstall() function pluginUninstall()
{ {
global $plugin,$admin_log,$pref,$tp,$sql; $pref = e107::getPref();
$admin_log = e107::getAdminLog();
$plugin = e107::getPlugin();
$tp = e107::getParser();
$sql = e107::getDb();
if(!isset($_POST['uninstall_confirm'])) if(!isset($_POST['uninstall_confirm']))
{ // $id is already an integer { // $id is already an integer
@@ -285,23 +290,18 @@ class pluginManager{
$plugin->manage_search('remove', $eplug_folder); $plugin->manage_search('remove', $eplug_folder);
$plugin->manage_notify('remove', $eplug_folder); $plugin->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);
$plugin->rebuildUrlConfig();
e107::getConfig('core')->save();
} }
$admin_log->log_event('PLUGMAN_03', $plug['plugin_path'], E_LOG_INFORMATIVE, ''); $admin_log->log_event('PLUGMAN_03', $plug['plugin_path'], E_LOG_INFORMATIVE, '');
if (isset($pref['plug_installed'][$plug['plugin_path']]))
{
unset($pref['plug_installed'][$plug['plugin_path']]);
if(save_prefs())
{
// echo "WORKED";
}
else
{
// echo "FAILED";
}
}
} }
if($_POST['delete_files']) if($_POST['delete_files'])
@@ -451,7 +451,9 @@ class pluginManager{
function pluginUpgrade() function pluginUpgrade()
{ {
global $plugin,$pref,$admin_log; $pref = e107::getPref();
$admin_log = e107::getAdminLog();
$plugin = e107::getPlugin();
$sql = e107::getDb(); $sql = e107::getDb();
@@ -489,54 +491,6 @@ class pluginManager{
} }
} }
/* Not used in 0.8
if ($eplug_module)
{
$plugin->manage_plugin_prefs('add', 'modules', $eplug_folder);
}
else
{
$plugin->manage_plugin_prefs('remove', 'modules', $eplug_folder);
}
if ($eplug_status)
{
$plugin->manage_plugin_prefs('add', 'plug_status', $eplug_folder);
}
else
{
$plugin->manage_plugin_prefs('remove', 'plug_status', $eplug_folder);
}
if ($eplug_latest)
{
$plugin->manage_plugin_prefs('add', 'plug_latest', $eplug_folder);
}
else
{
$plugin->manage_plugin_prefs('remove', 'plug_latest', $eplug_folder);
}
if (is_array($upgrade_add_eplug_sc))
{
$plugin->manage_plugin_prefs('add', 'plug_sc', $eplug_folder, $eplug_sc);
}
if (is_array($upgrade_remove_eplug_sc))
{
$plugin->manage_plugin_prefs('remove', 'plug_sc', $eplug_folder, $eplug_sc);
}
if (is_array($upgrade_add_eplug_bb))
{
$plugin->manage_plugin_prefs('add', 'plug_bb', $eplug_folder, $eplug_bb);
}
if (is_array($upgrade_remove_eplug_bb))
{
$plugin->manage_plugin_prefs('remove', 'plug_bb', $eplug_folder, $eplug_bb);
}
*/
if (is_array($upgrade_add_prefs)) if (is_array($upgrade_add_prefs))
{ {
$plugin->manage_prefs('add', $upgrade_add_prefs); $plugin->manage_prefs('add', $upgrade_add_prefs);
@@ -573,7 +527,10 @@ class pluginManager{
$text .= (isset($eplug_upgrade_done)) ? '<br />'.$eplug_upgrade_done : "<br />".LAN_UPGRADE_SUCCESSFUL; $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='$this->id' "); $sql->db_Update('plugin', "plugin_version ='{$eplug_version}', plugin_addons='{$eplug_addons}' WHERE plugin_id='$this->id' ");
$pref['plug_installed'][$plug['plugin_path']] = $eplug_version; // Update the version $pref['plug_installed'][$plug['plugin_path']] = $eplug_version; // Update the version
save_prefs();
e107::getConfig('core')->setPref($pref);
$plugin->rebuildUrlConfig();
e107::getConfig('core')->save();
} }

View File

@@ -29,22 +29,22 @@
<core name="contact_emailcopy">0</core> <core name="contact_emailcopy">0</core>
<core name="cookie_name">e107cookie</core> <core name="cookie_name">e107cookie</core>
<core name="core-infopanel-default"><![CDATA[array ( <core name="core-infopanel-default"><![CDATA[array (
0 => "e-administrator", 0 => 'e-administrator',
1 => "e-cpage", 1 => 'e-cpage',
2 => "e-filemanager", 2 => 'e-filemanager',
3 => "e-frontpage", 3 => 'e-frontpage',
4 => "e-image", 4 => 'e-image',
5 => "e-mailout", 5 => 'e-mailout',
6 => "e-menus", 6 => 'e-menus',
7 => "e-meta", 7 => 'e-meta',
8 => "e-newspost", 8 => 'e-newspost',
9 => "e-plugin", 9 => 'e-plugin',
10 => "e-prefs", 10 => 'e-prefs',
11 => "e-links", 11 => 'e-links',
12 => "e-theme", 12 => 'e-theme',
13 => "e-userclass2", 13 => 'e-userclass2',
14 => "e-users", 14 => 'e-users',
15 => "e-wmessage", 15 => 'e-wmessage',
)]]></core> )]]></core>
<core name="developer">0</core> <core name="developer">0</core>
<core name="disable_emailcheck">0</core> <core name="disable_emailcheck">0</core>
@@ -58,10 +58,10 @@
<core name="download_email">0</core> <core name="download_email">0</core>
<core name="e_jslib_browser_cache">0</core> <core name="e_jslib_browser_cache">0</core>
<core name="e_jslib_core"><![CDATA[array ( <core name="e_jslib_core"><![CDATA[array (
"prototype/prototype.js" => "all", 'prototype/prototype.js' => 'all',
"scriptaculous/scriptaculous.js" => "all", 'scriptaculous/scriptaculous.js' => 'all',
"scriptaculous/effects.js" => "all", 'scriptaculous/effects.js' => 'all',
"e107.js.php" => "all", 'e107.js.php' => 'all',
)]]></core> )]]></core>
<core name="e_jslib_plugin"><![CDATA[array ()]]></core> <core name="e_jslib_plugin"><![CDATA[array ()]]></core>
<core name="e_jslib_theme"><![CDATA[array ()]]></core> <core name="e_jslib_theme"><![CDATA[array ()]]></core>
@@ -77,10 +77,10 @@
<core name="forumdate">%a %b %d %Y, %I:%M%p</core> <core name="forumdate">%a %b %d %Y, %I:%M%p</core>
<core name="fpwcode">0</core> <core name="fpwcode">0</core>
<core name="frontpage"><![CDATA[array ( <core name="frontpage"><![CDATA[array (
0 => "news.php", 0 => 'index.php',
)]]></core> )]]></core>
<core name="frontpage_force"><![CDATA[array ( <core name="frontpage_force"><![CDATA[array (
0 => "", 0 => '',
)]]></core> )]]></core>
<core name="im_height">100</core> <core name="im_height">100</core>
<core name="im_path">/usr/X11R6/bin/</core> <core name="im_path">/usr/X11R6/bin/</core>
@@ -108,14 +108,14 @@
<core name="memberlist_access">253</core> <core name="memberlist_access">253</core>
<core name="membersonly_enabled">0</core> <core name="membersonly_enabled">0</core>
<core name="membersonly_exceptions"><![CDATA[array ( <core name="membersonly_exceptions"><![CDATA[array (
0 => "", 0 => '',
)]]></core> )]]></core>
<core name="menu_wordwrap"></core> <core name="menu_wordwrap"></core>
<core name="menuconfig_list"><![CDATA[array ( <core name="menuconfig_list"><![CDATA[array (
"login_menu" => 'login_menu' =>
array ( array (
"name" => "Login", 'name' => 'Login',
"link" => "login_menu/config.php", 'link' => 'login_menu/config.php',
), ),
)]]></core> )]]></core>
<core name="meta_tag"></core> <core name="meta_tag"></core>
@@ -180,24 +180,24 @@ City, State, Country
<core name="sitetheme_custompages"></core> <core name="sitetheme_custompages"></core>
<core name="sitetheme_deflayout">3_column</core> <core name="sitetheme_deflayout">3_column</core>
<core name="sitetheme_layouts"><![CDATA[array ( <core name="sitetheme_layouts"><![CDATA[array (
"3_column" => '3_column' =>
array ( array (
"@attributes" => '@attributes' =>
array ( array (
"title" => "3 Columns", 'title' => '3 Columns',
"preview" => "preview.jpg", 'preview' => 'preview.jpg',
"default" => "true", 'default' => 'true',
), ),
0 => "", 0 => '',
), ),
"2_column" => '2_column' =>
array ( array (
"@attributes" => '@attributes' =>
array ( array (
"title" => "2 Columns", 'title' => '2 Columns',
"preview" => "preview.jpg", 'preview' => 'preview.jpg',
), ),
0 => "", 0 => '',
), ),
)]]></core> )]]></core>
<core name="sitetheme_pref"></core> <core name="sitetheme_pref"></core>
@@ -216,6 +216,10 @@ City, State, Country
<core name="upload_class">255</core> <core name="upload_class">255</core>
<core name="upload_enabled">0</core> <core name="upload_enabled">0</core>
<core name="upload_maxfilesize"></core> <core name="upload_maxfilesize"></core>
<core name="url_aliases"><![CDATA[array()]]></core>
<core name="url_config"><![CDATA[array()]]></core>
<core name="url_locations"><![CDATA[array()]]></core>
<core name="url_modules"><![CDATA[array()]]></core>
<core name="useGeshi">0</core> <core name="useGeshi">0</core>
<core name="use_coppa">1</core> <core name="use_coppa">1</core>
<core name="user_reg">1</core> <core name="user_reg">1</core>
@@ -271,64 +275,64 @@ City, State, Country
<menu name="newforumposts_title">0</menu> <menu name="newforumposts_title">0</menu>
<menu name="update_menu">Update menu Settings</menu> <menu name="update_menu">Update menu Settings</menu>
<search name="comments_handlers"><![CDATA[array ( <search name="comments_handlers"><![CDATA[array (
"news" => 'news' =>
array ( array (
"id" => 0, 'id' => 0,
"dir" => "core", 'dir' => 'core',
"class" => "0", 'class' => '0',
), ),
"download" => 'download' =>
array ( array (
"id" => 2, 'id' => 2,
"dir" => "core", 'dir' => 'core',
"class" => "0", 'class' => '0',
), ),
)]]></search> )]]></search>
<search name="core_handlers"><![CDATA[array ( <search name="core_handlers"><![CDATA[array (
"news" => 'news' =>
array ( array (
"class" => "0", 'class' => '0',
"pre_title" => "0", 'pre_title' => '0',
"pre_title_alt" => "", 'pre_title_alt' => '',
"chars" => "150", 'chars' => '150',
"results" => "10", 'results' => '10',
"order" => "1", 'order' => '1',
), ),
"comments" => 'comments' =>
array ( array (
"class" => "0", 'class' => '0',
"pre_title" => "1", 'pre_title' => '1',
"pre_title_alt" => "", 'pre_title_alt' => '',
"chars" => "150", 'chars' => '150',
"results" => "10", 'results' => '10',
"order" => "2", 'order' => '2',
), ),
"users" => 'users' =>
array ( array (
"class" => "0", 'class' => '0',
"pre_title" => "1", 'pre_title' => '1',
"pre_title_alt" => "", 'pre_title_alt' => '',
"chars" => "150", 'chars' => '150',
"results" => "10", 'results' => '10',
"order" => "3", 'order' => '3',
), ),
"downloads" => 'downloads' =>
array ( array (
"class" => "0", 'class' => '0',
"pre_title" => "1", 'pre_title' => '1',
"pre_title_alt" => "", 'pre_title_alt' => '',
"chars" => "150", 'chars' => '150',
"results" => "10", 'results' => '10',
"order" => "4", 'order' => '4',
), ),
"pages" => 'pages' =>
array ( array (
"class" => "0", 'class' => '0',
"chars" => "150", 'chars' => '150',
"results" => "10", 'results' => '10',
"pre_title" => "0", 'pre_title' => '0',
"pre_title_alt" => "", 'pre_title_alt' => '',
"order" => "5", 'order' => '5',
), ),
)]]></search> )]]></search>
<search name="google">0</search> <search name="google">0</search>
@@ -341,50 +345,50 @@ City, State, Country
<search name="time_secs">60</search> <search name="time_secs">60</search>
<search name="user_select">1</search> <search name="user_select">1</search>
<notify name="event"><![CDATA[array ( <notify name="event"><![CDATA[array (
"usersup" => 'usersup' =>
array ( array (
"class" => "254", 'class' => '254',
"email" => "", 'email' => '',
), ),
"userveri" => 'userveri' =>
array ( array (
"class" => "254", 'class' => '254',
"email" => "", 'email' => '',
), ),
"login" => 'login' =>
array ( array (
"class" => "254", 'class' => '254',
"email" => "", 'email' => '',
), ),
"logout" => 'logout' =>
array ( array (
"class" => "254", 'class' => '254',
"email" => "", 'email' => '',
), ),
"flood" => 'flood' =>
array ( array (
"class" => "254", 'class' => '254',
"email" => "", 'email' => '',
), ),
"subnews" => 'subnews' =>
array ( array (
"class" => "254", 'class' => '254',
"email" => "", 'email' => '',
), ),
"newspost" => 'newspost' =>
array ( array (
"class" => "254", 'class' => '254',
"email" => "", 'email' => '',
), ),
"newsupd" => 'newsupd' =>
array ( array (
"class" => "254", 'class' => '254',
"email" => "", 'email' => '',
), ),
"newsdel" => 'newsdel' =>
array ( array (
"class" => "254", 'class' => '254',
"email" => "", 'email' => '',
), ),
)]]></notify> )]]></notify>
</prefs> </prefs>

View File

@@ -437,7 +437,6 @@ class eDispatcher
{ {
case 'plugin': case 'plugin':
if(!$plugin) return null; if(!$plugin) return null;
$location = $tmp[1];
return $sc ? '{e_PLUGIN}'.$plugin.'/controllers/' : e_PLUGIN.$plugin.'/controllers/'; return $sc ? '{e_PLUGIN}'.$plugin.'/controllers/' : e_PLUGIN.$plugin.'/controllers/';
break; break;
@@ -1036,6 +1035,7 @@ class eRouter
{ {
$ret['plugin'][] = $plugin; $ret['plugin'][] = $plugin;
} }
continue;
} }
// Register only those who don't need install and may be dispatchable // Register only those who don't need install and may be dispatchable
@@ -1066,6 +1066,19 @@ class eRouter
} }
} }
sort($ret['override']); sort($ret['override']);
// remove not installed plugin locations, possible only for 'all' type
if($type == 'all')
{
foreach ($ret['override'] as $i => $l)
{
// it's a plugin override, but not listed in current plugin array - remove
if(in_array($l, $plugins) && !in_array($l, $ret['plugin']))
{
unset($ret['override'][$i]);
}
}
}
} }
return $ret; return $ret;

View File

@@ -277,9 +277,10 @@ class e107plugin
// echo "Updated: ".$plug_path."<br />"; // echo "Updated: ".$plug_path."<br />";
} }
} }
if ($sp && vartrue($p_installed)) if ($sp/* && vartrue($p_installed)*/)
{ {
e107::getConfig('core')->setPref('plug_installed', $p_installed); e107::getConfig('core')->setPref('plug_installed', $p_installed);
$this->rebuildUrlConfig();
e107::getConfig('core')->save(); e107::getConfig('core')->save();
} }
} }
@@ -1074,6 +1075,30 @@ class e107plugin
$notify_prefs->save(false); $notify_prefs->save(false);
} }
/**
* Rebuild URL configuration values
* Note - new core system pref values will be set, but not saved
* e107::getConfig()->save() is required outside after execution of this method
* @return void
*/
public function rebuildUrlConfig()
{
$modules = eRouter::adminReadModules(); // get all available locations, non installed plugins will be ignored
$config = eRouter::adminBuildConfig(e107::getPref('url_config'), $modules); // merge with current config
$locations = eRouter::adminBuildLocations($modules); // rebuild locations pref
$aliases = eRouter::adminSyncAliases(e107::getPref('url_aliases'), $config); // rebuild aliases
// set new values, changes should be saved outside this methods
e107::getConfig()
->set('url_aliases', $aliases)
->set('url_config', $config)
->set('url_modules', $modules)
->set('url_locations', $locations);
eRouter::clearCache();
}
function displayArray(&$array, $msg = '') function displayArray(&$array, $msg = '')
{ {
$txt = ($msg ? $msg.'<br />' : ''); $txt = ($msg ? $msg.'<br />' : '');
@@ -1283,7 +1308,7 @@ class e107plugin
$p_installed[$plug['plugin_path']] = $plug_vars['@attributes']['version']; $p_installed[$plug['plugin_path']] = $plug_vars['@attributes']['version'];
e107::getConfig('core')->setPref('plug_installed', $p_installed); e107::getConfig('core')->setPref('plug_installed', $p_installed);
e107::getConfig('core')->save(); //e107::getConfig('core')->save(); - save triggered below
} }
if ($function == 'uninstall') if ($function == 'uninstall')
@@ -1294,6 +1319,8 @@ class e107plugin
} }
$this->rebuildUrlConfig();
e107::getConfig('core')->save(); e107::getConfig('core')->save();
/* if($function == 'install') /* if($function == 'install')
@@ -1870,7 +1897,11 @@ class e107plugin
$p_installed = e107::getPref('plug_installed', array()); // load preference; $p_installed = e107::getPref('plug_installed', array()); // load preference;
$p_installed[$plug['plugin_path']] = $plug['plugin_version']; $p_installed[$plug['plugin_path']] = $plug['plugin_version'];
e107::getConfig('core')->setPref('plug_installed', $p_installed)->save(); e107::getConfig('core')->setPref('plug_installed', $p_installed);
$this->rebuildUrlConfig();
e107::getConfig('core')->save();
$text .= (isset($eplug_done) ? "<br />{$eplug_done}" : "<br />".LAN_INSTALL_SUCCESSFUL); $text .= (isset($eplug_done) ? "<br />{$eplug_done}" : "<br />".LAN_INSTALL_SUCCESSFUL);
if ($eplug_conffile) if ($eplug_conffile)

View File

@@ -195,11 +195,11 @@ class e_pref extends e_front_model
public function set($pref_name, $value) public function set($pref_name, $value)
{ {
global $pref; global $pref;
if(empty($pref_name)) if(empty($pref_name) || !is_string($pref_name))
{ {
return $this; return $this;
} }
parent::set((string) $pref_name, $value, false); $this->_data[$pref_name] = $value;
//BC //BC
if($this->alias === 'core') if($this->alias === 'core')
@@ -220,11 +220,11 @@ class e_pref extends e_front_model
public function update($pref_name, $value) public function update($pref_name, $value)
{ {
global $pref; global $pref;
if(empty($pref_name)) if(empty($pref_name) || !is_string($pref_name))
{ {
return $this; return $this;
} }
parent::set((string) $pref_name, $value, true); if(isset($this->_data[$pref_name])) $this->_data[$pref_name] = $value;
//BC //BC
if($this->alias === 'core') if($this->alias === 'core')
@@ -249,8 +249,13 @@ class e_pref extends e_front_model
{ {
return $this; return $this;
} }
if(!isset($this->_data[$pref_name])) $this->_data[$pref_name] = $value;
$this->addData($pref_name, $value); //BC
if($this->alias === 'core')
{
$pref = $this->getData();
}
return $this; return $this;
} }
@@ -633,7 +638,7 @@ class e_pref extends e_front_model
* @param boolean $runtime clear runtime cache as well ($this->pref_cache) * @param boolean $runtime clear runtime cache as well ($this->pref_cache)
* @return e_pref * @return e_pref
*/ */
protected function clearPrefCache($cache_name = '', $runtime = true) public function clearPrefCache($cache_name = '', $runtime = true)
{ {
if($runtime) if($runtime)
{ {

View File

@@ -807,13 +807,20 @@ class xmlClass
return array(); return array();
} }
$mes = eMessage::getInstance(); //$mes = eMessage::getInstance();
$pref = array(); $pref = array();
foreach($XMLData['prefs'][$prefType] as $val) foreach($XMLData['prefs'][$prefType] as $val)
{ {
$name = $val['@attributes']['name']; $name = $val['@attributes']['name'];
$value = (substr($val['@value'],0,7) == "array (") ? e107::getArrayStorage()->ReadArray($val['@value']) : $val['@value']; // if(strpos($val['@value'], 'array (') === 0)
// {
// echo '<pre>'.$val['@value'];
// echo "\n";
// var_dump(e107::getArrayStorage()->ReadArray($val['@value']));
// echo $val['@value'].'</pre>';
// }
$value = strpos($val['@value'], 'array (') === 0 ? e107::getArrayStorage()->ReadArray($val['@value']) : $val['@value'];
$pref[$name] = $value; $pref[$name] = $value;
// $mes->add("Setting up ".$prefType." Pref [".$name."] => ".$value, E_MESSAGE_DEBUG); // $mes->add("Setting up ".$prefType." Pref [".$name."] => ".$value, E_MESSAGE_DEBUG);
@@ -839,30 +846,30 @@ class xmlClass
if($debug) if($debug)
{ {
// $message = print_r($xmlArray); //$message = print_r($xmlArray);
// echo "<pre>".print_r($xmlArray,TRUE)."</pre>"; echo "<pre>".var_export($xmlArray,TRUE)."</pre>";
return; return;
} }
$ret = array(); $ret = array();
//FIXME - doesn't work from install_.php.
if(vartrue($xmlArray['prefs'])) // Save Core Prefs if(vartrue($xmlArray['prefs'])) // Save Core Prefs
{ {
foreach($xmlArray['prefs'] as $type=>$array) foreach($xmlArray['prefs'] as $type=>$array)
{ {
$pArray = $this->e107ImportPrefs($xmlArray,$type); $pArray = $this->e107ImportPrefs($xmlArray,$type);
if($mode == 'replace') if($mode == 'replace') // merge with existing, add new
{ {
e107::getConfig($type)->setPref($pArray); e107::getConfig($type)->setPref($pArray);
} }
else // 'add' else // 'add' only new prefs
{ {
foreach ($pArray as $pname => $pval) foreach ($pArray as $pname => $pval)
{ {
e107::getConfig($type)->add($pname, $pval); // don't parse x/y/z e107::getConfig($type)->add($pname, $pval); // don't parse x/y/z
} }
// e107::getConfig($type)->addPref($pArray);
} }
if($debug == FALSE) if($debug == FALSE)