diff --git a/e107_admin/plugin.php b/e107_admin/plugin.php
index 8e9ba154f..7164579b6 100644
--- a/e107_admin/plugin.php
+++ b/e107_admin/plugin.php
@@ -52,6 +52,7 @@ $pman->pluginObserver();
require_once("footer.php");
exit;
+// FIXME switch to admin UI
class pluginManager{
var $plugArray;
@@ -193,11 +194,15 @@ class pluginManager{
}
-
+ // FIXME - move it to plugin handler, similar to install_plugin() routine
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']))
{ // $id is already an integer
$this->pluginConfirmUninstall($this->id);
@@ -285,23 +290,18 @@ class pluginManager{
$plugin->manage_search('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, '');
-
- 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'])
@@ -449,136 +449,93 @@ class pluginManager{
// -----------------------------------------------------------------------------
- function pluginUpgrade()
- {
- global $plugin,$pref,$admin_log;
+ function pluginUpgrade()
+ {
+ $pref = e107::getPref();
+ $admin_log = e107::getAdminLog();
+ $plugin = e107::getPlugin();
- $sql = e107::getDb();
+ $sql = e107::getDb();
- $emessage = eMessage::getInstance();
+ $emessage = eMessage::getInstance();
- $plug = $plugin->getinfo($this->id);
+ $plug = $plugin->getinfo($this->id);
- $_path = e_PLUGIN.$plug['plugin_path'].'/';
- if(file_exists($_path.'plugin.xml'))
+ $_path = e_PLUGIN.$plug['plugin_path'].'/';
+ if(file_exists($_path.'plugin.xml'))
+ {
+ $plugin->install_plugin_xml($this->id, 'upgrade');
+ }
+ else
+ {
+ include(e_PLUGIN.$plug['plugin_path'].'/plugin.php');
+
+ $func = $eplug_folder.'_upgrade';
+ if (function_exists($func))
{
- $plugin->install_plugin_xml($this->id, 'upgrade');
- }
- else
- {
- include(e_PLUGIN.$plug['plugin_path'].'/plugin.php');
-
- $func = $eplug_folder.'_upgrade';
- if (function_exists($func))
- {
- $text .= call_user_func($func);
- }
-
- if (is_array($upgrade_alter_tables))
- {
- $result = $plugin->manage_tables('upgrade', $upgrade_alter_tables);
- if (true !== $result)
- {
- //$text .= EPL_ADLAN_9.'
';
- $emessage->addWarning(EPL_ADLAN_9)
- ->addDebug($result);
- }
- else
- {
- $text .= EPL_ADLAN_7."
";
- }
- }
-
- /* 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))
- {
- $plugin->manage_prefs('add', $upgrade_add_prefs);
- $text .= EPL_ADLAN_8.'
';
- }
-
- if (is_array($upgrade_remove_prefs))
- {
- $plugin->manage_prefs('remove', $upgrade_remove_prefs);
- }
-
- if (is_array($upgrade_add_array_pref))
- {
- foreach($upgrade_add_array_pref as $key => $val)
- {
- $plugin->manage_plugin_prefs('add', $key, $eplug_folder, $val);
- }
- }
-
- if (is_array($upgrade_remove_array_pref))
- {
- foreach($upgrade_remove_array_pref as $key => $val)
- {
- $plugin->manage_plugin_prefs('remove', $key, $eplug_folder, $val);
- }
- }
-
- $plugin->manage_search('upgrade', $eplug_folder);
- $plugin->manage_notify('upgrade', $eplug_folder);
-
- $eplug_addons = $plugin -> getAddons($eplug_folder);
-
- $admin_log->log_event('PLUGMAN_02', $eplug_folder, E_LOG_INFORMATIVE, '');
- $text .= (isset($eplug_upgrade_done)) ? '
'.$eplug_upgrade_done : "
".LAN_UPGRADE_SUCCESSFUL;
- $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
- save_prefs();
+ $text .= call_user_func($func);
}
+ if (is_array($upgrade_alter_tables))
+ {
+ $result = $plugin->manage_tables('upgrade', $upgrade_alter_tables);
+ if (true !== $result)
+ {
+ //$text .= EPL_ADLAN_9.'
';
+ $emessage->addWarning(EPL_ADLAN_9)
+ ->addDebug($result);
+ }
+ else
+ {
+ $text .= EPL_ADLAN_7."
";
+ }
+ }
- $emessage->add($text, E_MESSAGE_SUCCESS);
- $plugin->save_addon_prefs();
+ if (is_array($upgrade_add_prefs))
+ {
+ $plugin->manage_prefs('add', $upgrade_add_prefs);
+ $text .= EPL_ADLAN_8.'
';
+ }
+
+ if (is_array($upgrade_remove_prefs))
+ {
+ $plugin->manage_prefs('remove', $upgrade_remove_prefs);
+ }
+
+ if (is_array($upgrade_add_array_pref))
+ {
+ foreach($upgrade_add_array_pref as $key => $val)
+ {
+ $plugin->manage_plugin_prefs('add', $key, $eplug_folder, $val);
+ }
+ }
+
+ if (is_array($upgrade_remove_array_pref))
+ {
+ foreach($upgrade_remove_array_pref as $key => $val)
+ {
+ $plugin->manage_plugin_prefs('remove', $key, $eplug_folder, $val);
+ }
+ }
+
+ $plugin->manage_search('upgrade', $eplug_folder);
+ $plugin->manage_notify('upgrade', $eplug_folder);
+
+ $eplug_addons = $plugin -> getAddons($eplug_folder);
+
+ $admin_log->log_event('PLUGMAN_02', $eplug_folder, E_LOG_INFORMATIVE, '');
+ $text .= (isset($eplug_upgrade_done)) ? '
'.$eplug_upgrade_done : "
".LAN_UPGRADE_SUCCESSFUL;
+ $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
+
+ e107::getConfig('core')->setPref($pref);
+ $plugin->rebuildUrlConfig();
+ e107::getConfig('core')->save();
+ }
+
+
+ $emessage->add($text, E_MESSAGE_SUCCESS);
+ $plugin->save_addon_prefs();
}
diff --git a/e107_core/xml/default_install.xml b/e107_core/xml/default_install.xml
index d704cca08..3eb35cde5 100644
--- a/e107_core/xml/default_install.xml
+++ b/e107_core/xml/default_install.xml
@@ -29,22 +29,22 @@
0
e107cookie
"e-administrator",
- 1 => "e-cpage",
- 2 => "e-filemanager",
- 3 => "e-frontpage",
- 4 => "e-image",
- 5 => "e-mailout",
- 6 => "e-menus",
- 7 => "e-meta",
- 8 => "e-newspost",
- 9 => "e-plugin",
- 10 => "e-prefs",
- 11 => "e-links",
- 12 => "e-theme",
- 13 => "e-userclass2",
- 14 => "e-users",
- 15 => "e-wmessage",
+ 0 => 'e-administrator',
+ 1 => 'e-cpage',
+ 2 => 'e-filemanager',
+ 3 => 'e-frontpage',
+ 4 => 'e-image',
+ 5 => 'e-mailout',
+ 6 => 'e-menus',
+ 7 => 'e-meta',
+ 8 => 'e-newspost',
+ 9 => 'e-plugin',
+ 10 => 'e-prefs',
+ 11 => 'e-links',
+ 12 => 'e-theme',
+ 13 => 'e-userclass2',
+ 14 => 'e-users',
+ 15 => 'e-wmessage',
)]]>
0
0
@@ -58,10 +58,10 @@
0
0
"all",
- "scriptaculous/scriptaculous.js" => "all",
- "scriptaculous/effects.js" => "all",
- "e107.js.php" => "all",
+ 'prototype/prototype.js' => 'all',
+ 'scriptaculous/scriptaculous.js' => 'all',
+ 'scriptaculous/effects.js' => 'all',
+ 'e107.js.php' => 'all',
)]]>
@@ -77,10 +77,10 @@
%a %b %d %Y, %I:%M%p
0
"news.php",
+ 0 => 'index.php',
)]]>
"",
+ 0 => '',
)]]>
100
/usr/X11R6/bin/
@@ -108,14 +108,14 @@
253
0
"",
+ 0 => '',
)]]>
+ 'login_menu' =>
array (
- "name" => "Login",
- "link" => "login_menu/config.php",
+ 'name' => 'Login',
+ 'link' => 'login_menu/config.php',
),
)]]>
@@ -180,24 +180,24 @@ City, State, Country
3_column
+ '3_column' =>
array (
- "@attributes" =>
+ '@attributes' =>
array (
- "title" => "3 Columns",
- "preview" => "preview.jpg",
- "default" => "true",
+ 'title' => '3 Columns',
+ 'preview' => 'preview.jpg',
+ 'default' => 'true',
),
- 0 => "",
+ 0 => '',
),
- "2_column" =>
+ '2_column' =>
array (
- "@attributes" =>
+ '@attributes' =>
array (
- "title" => "2 Columns",
- "preview" => "preview.jpg",
+ 'title' => '2 Columns',
+ 'preview' => 'preview.jpg',
),
- 0 => "",
+ 0 => '',
),
)]]>
@@ -216,6 +216,10 @@ City, State, Country
255
0
+
+
+
+
0
1
1
@@ -271,64 +275,64 @@ City, State, Country
+ 'news' =>
array (
- "id" => 0,
- "dir" => "core",
- "class" => "0",
+ 'id' => 0,
+ 'dir' => 'core',
+ 'class' => '0',
),
- "download" =>
+ 'download' =>
array (
- "id" => 2,
- "dir" => "core",
- "class" => "0",
+ 'id' => 2,
+ 'dir' => 'core',
+ 'class' => '0',
),
)]]>
+ 'news' =>
array (
- "class" => "0",
- "pre_title" => "0",
- "pre_title_alt" => "",
- "chars" => "150",
- "results" => "10",
- "order" => "1",
+ 'class' => '0',
+ 'pre_title' => '0',
+ 'pre_title_alt' => '',
+ 'chars' => '150',
+ 'results' => '10',
+ 'order' => '1',
),
- "comments" =>
+ 'comments' =>
array (
- "class" => "0",
- "pre_title" => "1",
- "pre_title_alt" => "",
- "chars" => "150",
- "results" => "10",
- "order" => "2",
+ 'class' => '0',
+ 'pre_title' => '1',
+ 'pre_title_alt' => '',
+ 'chars' => '150',
+ 'results' => '10',
+ 'order' => '2',
),
- "users" =>
+ 'users' =>
array (
- "class" => "0",
- "pre_title" => "1",
- "pre_title_alt" => "",
- "chars" => "150",
- "results" => "10",
- "order" => "3",
+ 'class' => '0',
+ 'pre_title' => '1',
+ 'pre_title_alt' => '',
+ 'chars' => '150',
+ 'results' => '10',
+ 'order' => '3',
),
- "downloads" =>
+ 'downloads' =>
array (
- "class" => "0",
- "pre_title" => "1",
- "pre_title_alt" => "",
- "chars" => "150",
- "results" => "10",
- "order" => "4",
+ 'class' => '0',
+ 'pre_title' => '1',
+ 'pre_title_alt' => '',
+ 'chars' => '150',
+ 'results' => '10',
+ 'order' => '4',
),
- "pages" =>
+ 'pages' =>
array (
- "class" => "0",
- "chars" => "150",
- "results" => "10",
- "pre_title" => "0",
- "pre_title_alt" => "",
- "order" => "5",
+ 'class' => '0',
+ 'chars' => '150',
+ 'results' => '10',
+ 'pre_title' => '0',
+ 'pre_title_alt' => '',
+ 'order' => '5',
),
)]]>
0
@@ -341,50 +345,50 @@ City, State, Country
60
1
+ 'usersup' =>
array (
- "class" => "254",
- "email" => "",
+ 'class' => '254',
+ 'email' => '',
),
- "userveri" =>
+ 'userveri' =>
array (
- "class" => "254",
- "email" => "",
+ 'class' => '254',
+ 'email' => '',
),
- "login" =>
+ 'login' =>
array (
- "class" => "254",
- "email" => "",
+ 'class' => '254',
+ 'email' => '',
),
- "logout" =>
+ 'logout' =>
array (
- "class" => "254",
- "email" => "",
+ 'class' => '254',
+ 'email' => '',
),
- "flood" =>
+ 'flood' =>
array (
- "class" => "254",
- "email" => "",
+ 'class' => '254',
+ 'email' => '',
),
- "subnews" =>
+ 'subnews' =>
array (
- "class" => "254",
- "email" => "",
+ 'class' => '254',
+ 'email' => '',
),
- "newspost" =>
+ 'newspost' =>
array (
- "class" => "254",
- "email" => "",
+ 'class' => '254',
+ 'email' => '',
),
- "newsupd" =>
+ 'newsupd' =>
array (
- "class" => "254",
- "email" => "",
+ 'class' => '254',
+ 'email' => '',
),
- "newsdel" =>
+ 'newsdel' =>
array (
- "class" => "254",
- "email" => "",
+ 'class' => '254',
+ 'email' => '',
),
)]]>
diff --git a/e107_handlers/application.php b/e107_handlers/application.php
index 0bbe1e4a7..341eb4b71 100644
--- a/e107_handlers/application.php
+++ b/e107_handlers/application.php
@@ -437,7 +437,6 @@ class eDispatcher
{
case 'plugin':
if(!$plugin) return null;
- $location = $tmp[1];
return $sc ? '{e_PLUGIN}'.$plugin.'/controllers/' : e_PLUGIN.$plugin.'/controllers/';
break;
@@ -1036,6 +1035,7 @@ class eRouter
{
$ret['plugin'][] = $plugin;
}
+ continue;
}
// Register only those who don't need install and may be dispatchable
@@ -1066,6 +1066,19 @@ class eRouter
}
}
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;
diff --git a/e107_handlers/plugin_class.php b/e107_handlers/plugin_class.php
index 8727d46f2..cb84764f2 100644
--- a/e107_handlers/plugin_class.php
+++ b/e107_handlers/plugin_class.php
@@ -277,9 +277,10 @@ class e107plugin
// echo "Updated: ".$plug_path."
";
}
}
- if ($sp && vartrue($p_installed))
+ if ($sp/* && vartrue($p_installed)*/)
{
e107::getConfig('core')->setPref('plug_installed', $p_installed);
+ $this->rebuildUrlConfig();
e107::getConfig('core')->save();
}
}
@@ -1074,6 +1075,30 @@ class e107plugin
$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 = '')
{
$txt = ($msg ? $msg.'
' : '');
@@ -1283,7 +1308,7 @@ class e107plugin
$p_installed[$plug['plugin_path']] = $plug_vars['@attributes']['version'];
e107::getConfig('core')->setPref('plug_installed', $p_installed);
- e107::getConfig('core')->save();
+ //e107::getConfig('core')->save(); - save triggered below
}
if ($function == 'uninstall')
@@ -1293,6 +1318,8 @@ class e107plugin
e107::getConfig('core')->setPref('plug_installed', $p_installed);
}
+
+ $this->rebuildUrlConfig();
e107::getConfig('core')->save();
@@ -1870,7 +1897,11 @@ class e107plugin
$p_installed = e107::getPref('plug_installed', array()); // load preference;
$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) ? "
{$eplug_done}" : "
".LAN_INSTALL_SUCCESSFUL);
if ($eplug_conffile)
diff --git a/e107_handlers/pref_class.php b/e107_handlers/pref_class.php
index 19036816a..ef87dad64 100644
--- a/e107_handlers/pref_class.php
+++ b/e107_handlers/pref_class.php
@@ -195,11 +195,11 @@ class e_pref extends e_front_model
public function set($pref_name, $value)
{
global $pref;
- if(empty($pref_name))
+ if(empty($pref_name) || !is_string($pref_name))
{
return $this;
}
- parent::set((string) $pref_name, $value, false);
+ $this->_data[$pref_name] = $value;
//BC
if($this->alias === 'core')
@@ -220,11 +220,11 @@ class e_pref extends e_front_model
public function update($pref_name, $value)
{
global $pref;
- if(empty($pref_name))
+ if(empty($pref_name) || !is_string($pref_name))
{
return $this;
}
- parent::set((string) $pref_name, $value, true);
+ if(isset($this->_data[$pref_name])) $this->_data[$pref_name] = $value;
//BC
if($this->alias === 'core')
@@ -249,8 +249,13 @@ class e_pref extends e_front_model
{
return $this;
}
-
- $this->addData($pref_name, $value);
+ if(!isset($this->_data[$pref_name])) $this->_data[$pref_name] = $value;
+
+ //BC
+ if($this->alias === 'core')
+ {
+ $pref = $this->getData();
+ }
return $this;
}
@@ -633,7 +638,7 @@ class e_pref extends e_front_model
* @param boolean $runtime clear runtime cache as well ($this->pref_cache)
* @return e_pref
*/
- protected function clearPrefCache($cache_name = '', $runtime = true)
+ public function clearPrefCache($cache_name = '', $runtime = true)
{
if($runtime)
{
diff --git a/e107_handlers/xml_class.php b/e107_handlers/xml_class.php
index 57ec76db3..5439da686 100644
--- a/e107_handlers/xml_class.php
+++ b/e107_handlers/xml_class.php
@@ -807,13 +807,20 @@ class xmlClass
return array();
}
- $mes = eMessage::getInstance();
+ //$mes = eMessage::getInstance();
$pref = array();
foreach($XMLData['prefs'][$prefType] as $val)
{
$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 ''.$val['@value'];
+ // echo "\n";
+ // var_dump(e107::getArrayStorage()->ReadArray($val['@value']));
+ // echo $val['@value'].'
';
+ // }
+ $value = strpos($val['@value'], 'array (') === 0 ? e107::getArrayStorage()->ReadArray($val['@value']) : $val['@value'];
$pref[$name] = $value;
// $mes->add("Setting up ".$prefType." Pref [".$name."] => ".$value, E_MESSAGE_DEBUG);
@@ -839,30 +846,30 @@ class xmlClass
if($debug)
{
- // $message = print_r($xmlArray);
- // echo "".print_r($xmlArray,TRUE)."
";
+ //$message = print_r($xmlArray);
+ echo "".var_export($xmlArray,TRUE)."
";
return;
}
$ret = array();
- //FIXME - doesn't work from install_.php.
+
if(vartrue($xmlArray['prefs'])) // Save Core Prefs
{
foreach($xmlArray['prefs'] as $type=>$array)
{
+
$pArray = $this->e107ImportPrefs($xmlArray,$type);
-
- if($mode == 'replace')
+
+ if($mode == 'replace') // merge with existing, add new
{
e107::getConfig($type)->setPref($pArray);
}
- else // 'add'
+ else // 'add' only new prefs
{
foreach ($pArray as $pname => $pval)
{
e107::getConfig($type)->add($pname, $pval); // don't parse x/y/z
}
- // e107::getConfig($type)->addPref($pArray);
}
if($debug == FALSE)