Index: extensions/AdditionalPages/additional_page.php
===================================================================
--- extensions/AdditionalPages/additional_page.php	(revision 9270)
+++ extensions/AdditionalPages/additional_page.php	(revision 9272)
@@ -6,5 +6,5 @@
 
 $page['section'] = 'additional_page';
-$identifier = $page['is_homepage'] ? $conf['additional_pages']['homepage'] : $tokens[1];
+$identifier = $page['ap_homepage'] ? $conf['additional_pages']['homepage'] : $tokens[1];
 
 load_language('plugin.lang.php', AP_PATH);
@@ -25,11 +25,16 @@
 if (empty($row))
 {
-  if ($page['is_homepage']) return;
+  if ($page['ap_homepage']) return;
   page_not_found('Requested page does not exist');
 }
 
-if (is_numeric($identifier) and !empty($row['permalink']) and !$page['is_homepage'])
+if (is_numeric($identifier) and !empty($row['permalink']) and !$page['ap_homepage'])
 {
   redirect(make_index_url().'/page/' . $row['permalink']);
+}
+
+if (!$page['ap_homepage'] and $row['id'] == $conf['additional_pages']['homepage'])
+{
+  redirect(make_index_url());
 }
 
@@ -48,5 +53,5 @@
   if (!is_admin() and $conf['additional_pages']['user_perm'] and !in_array($user['status'], $authorized_users))
   {
-    if ($page['is_homepage']) return;
+    if ($page['ap_homepage']) return;
   	page_forbidden(l10n('You are not authorized to access the requested page'));
   }
@@ -62,5 +67,5 @@
   if (!is_admin() and $conf['additional_pages']['group_perm'] and empty($array))
   {
-    if ($page['is_homepage']) return;
+    if ($page['ap_homepage']) return;
   	page_forbidden(l10n('You are not authorized to access the requested page'));
   }
@@ -85,8 +90,8 @@
   );
 
-  if ($conf['additional_pages']['show_home'])
+  if ($conf['additional_pages']['show_home'] and !$page['ap_homepage'])
   {
     $template->assign('PLUGIN_INDEX_ACTIONS' , '
-      <li><a href="'.make_index_url().'/categories" title="' . l10n('return to homepage') . '">
+      <li><a href="'.make_index_url().'" title="' . l10n('return to homepage') . '">
         <img src="' . $template->get_themeconf('icon_dir') . '/home.png" class="button" alt="' . l10n('home') . '"/></a>
       </li>');
Index: extensions/AdditionalPages/admin/add_page.inc.php
===================================================================
--- extensions/AdditionalPages/admin/add_page.inc.php	(revision 9270)
+++ extensions/AdditionalPages/admin/add_page.inc.php	(revision 9272)
@@ -83,5 +83,5 @@
     {
       $conf['additional_pages']['homepage'] = isset($_POST['homepage']) ? $edited_page['id'] : null;
-      pwg_query('UPDATE '.CONFIG_TABLE.' SET value = "'.addslashes(serialize($conf['additional_pages'])).'" WHERE param = "additional_pages";');
+      conf_update_param('additional_pages', pwg_db_real_escape_string(serialize($conf['additional_pages'])));
     }
 
Index: extensions/AdditionalPages/admin/admin.php
===================================================================
--- extensions/AdditionalPages/admin/admin.php	(revision 9270)
+++ extensions/AdditionalPages/admin/admin.php	(revision 9272)
@@ -15,11 +15,9 @@
 $page_exist = array_from_query($query, 'id');
 
-if (!isset($_GET['tab']))
+$page['tab'] = isset($_GET['tab']) ? $_GET['tab'] : 'manage';
+
+if (!$page_exist and $page['tab'] == 'manage')
 {
-  $page['tab'] = $page_exist ? 'manage' : 'add_page';
-}
-else
-{
-  $page['tab'] = $_GET['tab'];
+  redirect($my_base_url.'&amp;tab=add_page');
 }
 
Index: extensions/AdditionalPages/admin/config.inc.php
===================================================================
--- extensions/AdditionalPages/admin/config.inc.php	(revision 9270)
+++ extensions/AdditionalPages/admin/config.inc.php	(revision 9272)
@@ -2,4 +2,6 @@
 
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
+
+$mb_conf = @unserialize($conf['blk_menubar']);
 
 // Enregistrement de la configuration
@@ -8,27 +10,30 @@
   $params = array('show_home', 'group_perm', 'user_perm');
 
-  $new_conf = array();
   foreach ($params as $param)
   {
-    $new_conf[$param] = isset($_POST[$param]);
+    $conf['additional_pages'][$param] = isset($_POST[$param]);
   }
 
-  $new_conf['languages'] = array();
+  $conf['additional_pages']['languages'] = array();
 	foreach($_POST['menu_lang'] as $language_code => $name)
   {
 		if (!empty($name))
-      $new_conf['languages'][$language_code] = $name;
+      $conf['additional_pages']['languages'][$language_code] = $name;
 	}
 
-  $new_conf['homepage'] = $conf['additional_pages']['homepage'];
+  conf_update_param('additional_pages', pwg_db_real_escape_string(serialize($conf['additional_pages'])));
 
-    $query = '
-UPDATE ' . CONFIG_TABLE . '
-  SET value="'.addslashes(serialize($new_conf)).'"
-  WHERE param="additional_pages"
-  LIMIT 1';
-    pwg_query($query);
-    array_push($page['infos'], l10n('ap_conf_saved'));
-    $conf['additional_pages'] = $new_conf;
+  if (isset($_POST['show_menu']) xor (!isset($mb_conf['mbAdditionalPages']) or $mb_conf['mbAdditionalPages'] == abs($mb_conf['mbAdditionalPages'])))
+  {
+    if (!isset($mb_conf['mbAdditionalPages']))
+    {
+      $last = @abs(end($mb_conf));
+      $mb_conf['mbAdditionalPages'] = $last + 50;
+    }
+    $mb_conf['mbAdditionalPages'] = (isset($_POST['show_menu']) ? +1 : -1) * abs($mb_conf['mbAdditionalPages']);
+    conf_update_param('blk_menubar', pwg_db_real_escape_string(serialize($mb_conf)));
+  }
+
+  array_push($page['infos'], l10n('ap_conf_saved'));
 }
 
@@ -48,4 +53,9 @@
 $template->assign('ap_conf', $conf['additional_pages']);
 
+if (!isset($mb_conf['mbAdditionalPages']) or $mb_conf['mbAdditionalPages'] == abs($mb_conf['mbAdditionalPages']))
+{
+  $template->assign('SHOW_MENU', true);
+}
+
 $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/template/config.tpl'));
 $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
Index: extensions/AdditionalPages/admin/edit_page.inc.php
===================================================================
--- extensions/AdditionalPages/admin/edit_page.inc.php	(revision 9270)
+++ extensions/AdditionalPages/admin/edit_page.inc.php	(revision 9272)
@@ -16,5 +16,5 @@
   {
     $conf['additional_pages']['homepage'] = null;
-    pwg_query('UPDATE '.CONFIG_TABLE.' SET value = "'.addslashes(serialize($conf['additional_pages'])).'" WHERE param = "additional_pages";');
+    conf_update_param('additional_pages', pwg_db_real_escape_string(serialize($conf['additional_pages'])));
   }
   redirect($my_base_url.'&page_deleted=');
Index: extensions/AdditionalPages/admin/template/config.tpl
===================================================================
--- extensions/AdditionalPages/admin/template/config.tpl	(revision 9270)
+++ extensions/AdditionalPages/admin/template/config.tpl	(revision 9272)
@@ -7,10 +7,4 @@
 	<legend>{'ap_config'|@translate}</legend>
 	<table>
-		<tr>
-			<td colspan="3"><input type="checkbox" name="show_home" value="on" {if $ap_conf.show_home}checked="checked"{/if}/> {'ap_show_home'|@translate}</td>
-		</tr>
-		<tr>
-			<td colspan="3"><br><hr><br></td>
-		</tr>
 		<tr>
 			<td colspan="3">{'ap_perm'|@translate}</td>
@@ -25,5 +19,11 @@
 			<td colspan="3"><br><hr><br></td>
 		</tr>
-		<tr>
+    <tr>
+			<td colspan="3"><input type="checkbox" name="show_home" value="on" {if $ap_conf.show_home}checked="checked"{/if}/> {'ap_show_home'|@translate}</td>
+		</tr>
+    <tr>
+			<td colspan="3"><input type="checkbox" name="show_menu" value="on" {if isset($SHOW_MENU)}checked="checked"{/if}/> {'ap_show_menu'|@translate}</td>
+		</tr>
+		<tr class="menu_languages">
 			<td><br>{'ap_menu_name'|@translate} : &nbsp;&nbsp;</td>
 			<td><br>{'Default'|@translate}&nbsp;&nbsp;</td>
@@ -31,5 +31,5 @@
 		</tr>
 		{foreach from=$language item=lang}
-		<tr>
+		<tr class="menu_languages">
 			<td></td>
 			<td>{$lang.LANGUAGE_NAME}&nbsp;&nbsp;</td>
@@ -47,2 +47,15 @@
 	<p><a href="{$convert_bbcode.PATH}">{'ap_parse_bbcode'|@translate}</a></p>
 {/if}
+
+<script type="text/javascript">
+jQuery().ready( function () {ldelim}
+  jQuery("input[name='show_menu']").click( function() {ldelim}
+    if (this.checked)
+      jQuery('.menu_languages').show();
+    else
+      jQuery('.menu_languages').hide();
+  });
+});
+if (!jQuery("input[name='show_menu']").attr('checked'))
+  jQuery('.menu_languages').hide();
+</script>
Index: extensions/AdditionalPages/admin/upgrade_from_21.php
===================================================================
--- extensions/AdditionalPages/admin/upgrade_from_21.php	(revision 9270)
+++ extensions/AdditionalPages/admin/upgrade_from_21.php	(revision 9272)
@@ -19,5 +19,5 @@
 SELECT id, pos, title, lang
 FROM '.$prefixeTable.'additionalpages
-ORDER BY pos ASC, id ASC
+ORDER BY pos ASC
 ;';
 $result = pwg_query($query);
@@ -43,5 +43,5 @@
   $position = $row['pos'];
   if ($row['pos'] === '0')
-    $position = '-1';
+    $position = '-100';
   elseif (empty($row['pos']))
     $position = '0';
@@ -61,5 +61,18 @@
 }
 
+load_conf_from_db('param = "additional_pages"');
 $old_conf = explode ("," , $conf['additional_pages']);
+
+if ($old_conf[1] == 'off')
+{
+  $mb_conf = @unserialize($conf['blk_menubar']);
+  if (!isset($mb_conf['mbAdditionalPages']))
+  {
+    $last = @abs(end($mb_conf));
+    $mb_conf['mbAdditionalPages'] = $last + 50;
+  }
+  $mb_conf['mbAdditionalPages'] = -1 * abs($mb_conf['mbAdditionalPages']);
+  conf_update_param('blk_menubar', pwg_db_real_escape_string(serialize($mb_conf)));
+}
 
 $new_conf = array(
@@ -81,10 +94,5 @@
 $conf['additional_pages'] = $new_conf;
 
-$query = '
-UPDATE '.CONFIG_TABLE.'
-SET value = "'.addslashes(serialize($new_conf)).'"
-WHERE param = "additional_pages"
-;';
-pwg_query($query);
+conf_update_param('additional_pages', pwg_db_real_escape_string(serialize($new_conf)));
 
 ?>
Index: extensions/AdditionalPages/index_menu.php
===================================================================
--- extensions/AdditionalPages/index_menu.php	(revision 9270)
+++ extensions/AdditionalPages/index_menu.php	(revision 9272)
@@ -65,6 +65,11 @@
           (!$conf['additional_pages']['user_perm'] or empty($row['users']) or in_array($user['status'], $authorized_users))))
         {
+          $url = make_index_url();
+          if ($row['id'] != $conf['additional_pages']['homepage'])
+          {
+            $url .= '/page/'.(isset($row['permalink']) ? $row['permalink'] : $row['id']);
+          }
           array_push($data, array(
-            'URL' => make_index_url().'/page/'.(isset($row['permalink']) ? $row['permalink'] : $row['id']),
+            'URL' => $url,
             'LABEL' => $row['title']));
         }
Index: extensions/AdditionalPages/main.inc.php
===================================================================
--- extensions/AdditionalPages/main.inc.php	(revision 9270)
+++ extensions/AdditionalPages/main.inc.php	(revision 9272)
@@ -34,7 +34,7 @@
   global $tokens, $conf, $page;
 
-  $page['is_homepage'] = (count($tokens) == 1 and empty($tokens[0]));
+  $page['ap_homepage'] = (count($tokens) == 1 and empty($tokens[0]));
 
-  if (($tokens[0] == 'page' and !empty($tokens[1])) or ($page['is_homepage'] and !is_null($conf['additional_pages']['homepage'])))
+  if (($tokens[0] == 'page' and !empty($tokens[1])) or ($page['ap_homepage'] and !is_null($conf['additional_pages']['homepage'])))
     include(AP_PATH . 'additional_page.php');
 
Index: extensions/AdditionalPages/maintain.inc.php
===================================================================
--- extensions/AdditionalPages/maintain.inc.php	(revision 9270)
+++ extensions/AdditionalPages/maintain.inc.php	(revision 9272)
@@ -18,5 +18,5 @@
 groups VARCHAR( 255 ) NULL DEFAULT NULL ,
 permalink VARCHAR( 64 ) NULL DEFAULT NULL ,
-standalone ENUM( "true", "false" ) NOT NULL DEFAULT "false"
+standalone ENUM( "true", "false" ) NOT NULL DEFAULT "false" ,
 PRIMARY KEY (id) ,
 INDEX (pos) ,
@@ -35,6 +35,7 @@
       'homepage' => null,
     );
+
     $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
-VALUES ("additional_pages" , "'.addslashes(serialize($config)).'" , "Additional Pages config configuration");';
+VALUES ("additional_pages" , "'.pwg_db_real_escape_string(serialize($config)).'" , "Additional Pages config configuration");';
     pwg_query($query);
   }
