Index: /extensions/event_cats/include/ec_conf.inc.php
===================================================================
--- /extensions/event_cats/include/ec_conf.inc.php	(revision 7083)
+++ /extensions/event_cats/include/ec_conf.inc.php	(revision 7084)
@@ -33,4 +33,15 @@
 // ---------------------------------------------------------------------------
 
+// ----- Introduction
+// Not sure I'm very proud of this quite complex configuration initialization
+// part :-/ ...
+// The reason of the complexity is the inital intention of building a
+// configuration management allowing to use in the rest of the script only
+// two functions: change_ec_conf() and read_ec_conf() .
+// change_ec_conf() updates the DB systematically. The initialization part
+// has the only function of determining what is the value of $ec_conf, which
+// is the root configuration parameters provider.
+// -----
+
 // $ec_conf has numeric indexes (instead of string keys like 'activated',
 // 'howto'...) because of its first reading, done with the "explode" function.
@@ -52,7 +63,4 @@
 
 //----------------------------------------------------------------------------
-// The following lines allow to change the number of configuration items, the
-// default values they can have, and also their possible other values, very
-// quickly.
 
 // Give possible $ec_conf values. In case values cannot be predicted, just
@@ -60,16 +68,58 @@
 $ec_conf_possible_values = array(
   'activated'           => array('0', '1'),                           //  0
+    // plugin activated
   'howto'               => array('0', '1'),                           //  1
+    // whether the small aknowledgement message has already been displayed
   'dup_allow'           => array('0', '1', '2'),                      //  2
+    // duplication allowance :
+    //   0 : no account;
+    //   1 : all accounts;
+    //   2 : specified by group, type, and user ids (default).
+    // If Event Cats is in "simple mode", get the value of
+    // $conf['ec_dup_allow'] if it is set; and an allowance to duplicate only
+    // generic accounts will be defined if the value is 2.
   'duplic_display'      => array('0', '1', '2'),                      //  3
+    // duplication link display in the menubar :
+    //   0 : "Register" for everybody;
+    //   1 : "Duplicate" for everybody;
+    //   2 : "Register" only for generic accounts,
+    //       "Duplicate" for all other accounts (default);
+    // If Event Cats is in "simple mode", takes the value of
+    // $conf['ec_duplic_display'] if it's set.
   'auto_code_dg_nb'     => array( '4',  '5',  '8', '10', '12', '15',
                                  '16', '20', '24', '25', '30', '32'), //  4
+    // number of digits when creating a new code automatically, several values
+    // (default: 10)
+    // If Event Cats is in "simple mode", get the value of
+    // $conf['ec_auto_code_dg_nb'] if set.
   'unknown_code'        => array('0', '1', '2'),                      //  5
+    // what to do in case an unknown code is used with "autolog" parameter :
+    //   0 : nothing (display home page, index.php (not logged in of course));
+    //   1 : display "access denied" page (default);
+    //   2 : display an A. P. precised below.
   'unknown_code_ap_id'  => array(),                                   //  6
+    // the id of the Additional Page which must be used in case of usage of an
+    // unknow code; several vals (default: 0).
   'comment_display'     => array('0', '1'),                           //  7
+    // the way the comment is displayed in "entries" tab:
+    // 0, as tooltip; 1 (default), on a line under code
+    // If Event Cats is in "simple mode", get the value of
+    // $conf['ec_comment_display'] if set.
   'in_help_display'     => array('0', '1'),                           //  8
+    // whether the help banner is displayed (default: 1).
   'display_connection'  => array('0', '1'),                           //  9
+    // whether the "Connection" link must be displayed for generic users
+    // (default: 1)
+    // If Event Cats is in "simple mode", takes the value of
+    // $conf['ec_display_connection'] if set.
   'simple_mode_on'      => array('0', '1'),                           // 10
+    // whether the presentation of the plugin is in "simple mode" or not.
+    // (default: 1)
+    // The default value can be modified to 0 (normal view) if Event Cats was
+    // already installed previously.
   'display_full_button' => array('0', '1'),                           // 11
+    // whether the "Show full features" button must be displayed (default: 1).
+    // The default value can be modified to 0 (don't display) if
+    // $conf['ec_display_full_button'] is set, and false.
 );
 
@@ -81,5 +131,5 @@
 $t = array(); $u = '0'; $v = false; $w = false; $ec_conf = array(); $s = '0';
 if ($w = ( // $w becomes true if the query succeeds <=> if EC was already in
-  // $t gets event_cats config value, as an array with one unique entry
+  // $t gets event_cats config value (array to be "exploded")
   ($t = pwg_db_fetch_row(pwg_query("
     SELECT `value`
@@ -89,7 +139,7 @@
 ) {
   $v = (count($ec_conf = explode(',', $t[0])) == count($ec_conf_index));
-  $u = $ec_conf[0];
-  $s = ($v) ? $ec_conf[1] : '0'; // the aknowledgement message is displayed
-  // again if the configuration changes
+  $u = $ec_conf[$ec_conf_index['activated']];
+  $s = ($v) ? $ec_conf[$ec_conf_index['howto']] : '0'; // the aknowledgement
+  // message is displayed again if the configuration changes
 }
 if ($v and !$w) die('$v true with $w false in ec_conf.inc.php');
@@ -97,14 +147,16 @@
 // $v is false if the entry in the table doesn't exist; or exists, but its
 // number of parameters is different than the number of default parameters.
-// $u is '0' if the plugin has not yet been activated, '1' if it has been.
+// $u is '0' if the plugin is not activated, '1' if it is.
 // $s allows to display the aknowledgement message when config changes.
 // If $v or $w are false, all $ec_conf values are set to default values. But
 // default values must first take values specified in $conf, if they are set.
 
-// Determine whether simple mode is ON or OFF
+// Determine whether simple mode is ON or OFF: simple mode must be on if Event
+// Cats is just installed, or if it was ON previously, or if
+// $conf['ec_display_full_button'] is set and is false.
 $simple_mode_on = (
   (!$v and !$w) or (
-    // $ec_conf[10] <=> read_ec_conf('simple_mode_on')
-    isset($ec_conf[10]) and $ec_conf[10] == '1'
+    isset($ec_conf[$ec_conf_index['simple_mode_on']]) and
+    $ec_conf[$ec_conf_index['simple_mode_on']] == '1'
   ) or (
     isset($conf['ec_display_full_button']) and
@@ -113,129 +165,95 @@
 );
 
-if (!$v) {
-  // Give configuration items names and default values. Only strings.
-  $ec_conf_default = array( // PLUGIN CONFIGURATION ($ec_conf) :
-                            // ---------------------------------
-    'activated'       //  0 // plugin activated, 0 or 1
-      => $u,                // 
-                            // 
-    'howto'           //  1 // whether the small aknowledgement message has
-      => $s,                // already been displayed, 0 or 1
-                            // 
-    'dup_allow' => ($simple_mode_on and isset($conf['ec_dup_allow']) and
-                    in_array($conf['ec_dup_allow'],
-                    $ec_conf_possible_values['ec_dup_allow'])) ?
-      $conf['ec_dup_allow'] : (isset($ec_conf[2]) and in_array($ec_conf[2],
-      $ec_conf_possible_values['dup_allow'])) ? $ec_conf[2] : '2',
-                      //  2 // duplication allowance :
-                            //   0 : no account;
-                            //   1 : all accounts;
-                            //   2 : specified by group, type, and user ids.
-                            // If Event Cats is in "simple mode", takes the
-                            // value of $conf['ec_dup_allow'] if it is set;
-                            // and an allowance to duplicate only generic
-                            // accounts will be defined.
-                            // 
-    'duplic_display' => ($simple_mode_on and isset($conf['ec_duplic_display'])
-                    and in_array($conf['ec_duplic_display'],
-                    $ec_conf_possible_values['ec_duplic_display'])) ?
-      $conf['ec_duplic_display'] : (isset($ec_conf[3]) and
-      in_array($ec_conf[3], $ec_conf_possible_values['duplic_display'])) ?
-      $ec_conf[3] : '2',
-                      //  3 // duplication link display in the menubar :
-                            //   0 : "Register" for everybody;
-                            //   1 : "Duplicate" for everybody;
-                            //   2 : "Register" only for generic accounts,
-                            //       "Duplicate" for all other accounts;
-                            // If Event Cats is in "simple mode", takes the
-                            // value of $conf['ec_duplic_display'] if it's set.
-                            // 
-  'auto_code_dg_nb' => ($simple_mode_on and isset($conf['ec_auto_code_dg_nb'])
-                    and in_array($conf['ec_auto_code_dg_nb'],
-                    $ec_conf_possible_values['ec_auto_code_dg_nb'])) ?
-      $conf['ec_auto_code_dg_nb'] : (isset($ec_conf[4]) and
-      in_array($ec_conf[4], $ec_conf_possible_values['auto_code_dg_nb'])) ?
-      $ec_conf[4] : '10',
-                      //  4 // number of digits when creating a new code
-                            // automatically, several values
-                            // If Event Cats is in "simple mode", takes the
-                            // value of $conf['ec_auto_code_dg_nb'] if set.
-                            // 
-    'unknown_code'    //  5 // what to do in case an unknown code is used with
-      => (isset($ec_conf[5]) and in_array($ec_conf[5],
-      $ec_conf_possible_values['unknown_code'])) ? $ec_conf[5] : '1',
-                            // "autolog" parameter :
-                            //   0 : nothing (display home page, index.php
-                            //       (not logged in of course));
-                            //   1 : display "access denied" page;
-                            //   2 : display an A. P. precised below.
-                            // 
-    'unknown_code_ap_id' // 6| the id of the Additional Page which must be
-      => (isset($ec_conf[6])) ? $ec_conf[6] : '0',
-                            // used in case of usage of an unknow code;
-                            // several vals.
-                            // 
-    'comment_display' => ($simple_mode_on and isset($conf['ec_comment_display'])
-                    and in_array($conf['ec_comment_display'],
-                    $ec_conf_possible_values['ec_comment_display'])) ?
-      $conf['ec_comment_display'] : (isset($ec_conf[7]) and
-      in_array($ec_conf[7], $ec_conf_possible_values['comment_display'])) ?
-      $ec_conf[7] : '1',
-                      //  7 // the way the comment is displayed in "entries"
-                            // tab : 0, as tooltip; 1, on a line under code
-                            // If Event Cats is in "simple mode", takes the
-                            // value of $conf['ec_comment_display'] if set.
-                            // 
-    'in_help_display' //  8 // whether the help banner is displayed.
-      => (isset($ec_conf[8]) and in_array($ec_conf[8],
-      $ec_conf_possible_values['in_help_display'])) ? $ec_conf[8] : '1',
-                            // 0: not displayed; 1 : displayed (surprising !)
-                            // 
-    'display_connection' => ($simple_mode_on and
-                    isset($conf['ec_display_connection']) and
-                    in_array($conf['ec_display_connection'],
-                    $ec_conf_possible_values['ec_display_connection'])) ?
-      $conf['ec_display_connection'] : (isset($ec_conf[9]) and
-      in_array($ec_conf[9], $ec_conf_possible_values['display_connection'])) ?
-      $ec_conf[9] : '1',
-                      //  9 // whether the "Connection" link must be displayed
-                            // for generic users, 0 or 1.
-                            // If Event Cats is in "simple mode", takes the
-                            // value of $conf['ec_display_connection'] if set.
-                            // 
-    'simple_mode_on' => ($simple_mode_on) ?
-      '1' : '0',      // 10 // whether the presentation of the plugin is in
-                            // "simple mode" or not.
-                            // 0: normal view; 1 : simple view.
-                            // The default value can be modified to 0 (normal
-                            // view) if Event Cats was already installed
-                            // previously.
-                            // 
-    'display_full_button' => ($simple_mode_on and
-                    isset($conf['ec_display_full_button']) and
-                    in_array($conf['ec_display_full_button'],
-                    $ec_conf_possible_values['ec_display_full_button'])) ?
-      $conf['ec_display_full_button'] : (isset($ec_conf[11]) and
-    in_array($ec_conf[11], $ec_conf_possible_values['display_full_button'])) ?
-       $ec_conf[11] : '1',
-                      // 11 // whether the "Show full features" button must be
-                            // displayed, 0 or 1. The default value can be
-                            // modified to 0 (don't display) if
-                            // $conf['ec_display_full_button'] has val. false.
-  );
+// Change $ec_conf values if needed
+if (!$v or $simple_mode_on) {
   
-// Once these lines have been updated, you don't need to change anything
-// else. Everything is managed by the code.
-//----------------------------------------------------------------------------
-
-  // Set $ec_conf to proper default values if needed, and writes its values
-  // in the DB
-  $ec_conf = array_values($ec_conf_default);
-
-  change_ec_conf('activated', $u); // writes in the DB
+  // Perform repetitve work
+  function test_conf($tbl, $k, $k2 = NULL) {
+  global $ec_conf_possible_values;
+    if (!isset($k2)) $k2 = $k;
+    return (isset($tbl[$k]) and
+     in_array($tbl[$k], $ec_conf_possible_values[$k2]));
+  }
+  
+  // Avoid that $conf (very big) is passed as argument to function test_conf
+  $conf_temp = array();
+  foreach ($ec_conf_possible_values as $key => $val)
+   if (isset($conf['ec_'.$key])) $conf_temp[$key] = $conf['ec_'.$key];
+  
+  if (!$v) {
+    // Determine default values of $ec_conf
+    $ec_conf = array(
+      $ec_conf_index['activated'] => $u,
+      $ec_conf_index['howto'] => $s,
+      $ec_conf_index['dup_allow'] =>
+        ($simple_mode_on and test_conf($conf_temp, 'dup_allow')) ?
+          $conf_temp['dup_allow']
+          : (test_conf($ec_conf, $ec_conf_index['dup_allow'], 'dup_allow')) ? 
+            $ec_conf[$ec_conf_index['dup_allow']]
+            : '2',
+      $ec_conf_index['duplic_display'] =>
+        ($simple_mode_on and test_conf($conf_temp, 'duplic_display')) ?
+          $conf_temp['duplic_display']
+          : (test_conf($ec_conf, $ec_conf_index['duplic_display'],
+             'duplic_display')) ?
+            $ec_conf[$ec_conf_index['duplic_display']]
+            : '2',
+      $ec_conf_index['auto_code_dg_nb'] =>
+        ($simple_mode_on and test_conf($conf_temp, 'auto_code_dg_nb')) ?
+          $conf_temp['auto_code_dg_nb']
+          : (test_conf($ec_conf, $ec_conf_index['auto_code_dg_nb'],
+             'auto_code_dg_nb')) ?
+            $ec_conf[$ec_conf_index['auto_code_dg_nb']]
+            : '10',
+      $ec_conf_index['unknown_code'] =>
+        (test_conf($ec_conf, $ec_conf_index['unknown_code'],
+         'unknown_code')) ?
+          $ec_conf[$ec_conf_index['unknown_code']]
+          : '1',
+      $ec_conf_index['unknown_code_ap_id'] =>
+        (isset($ec_conf[$ec_conf_index['unknown_code_ap_id']])) ?
+          $ec_conf[$ec_conf_index['unknown_code_ap_id']]
+          : '0',
+      $ec_conf_index['comment_display'] =>
+        ($simple_mode_on and test_conf($conf_temp, 'comment_display')) ?
+          $conf_temp['comment_display']
+          : (test_conf($ec_conf, $ec_conf_index['comment_display'],
+             'comment_display')) ?
+            $ec_conf[$ec_conf_index['comment_display']]
+            : '1',
+      $ec_conf_index['in_help_display'] =>
+        (test_conf($ec_conf, $ec_conf_index['in_help_display'],
+         'in_help_display')) ?
+            $ec_conf[$ec_conf_index['in_help_display']]
+            : '1',
+      $ec_conf_index['display_connection'] =>
+        ($simple_mode_on and test_conf($conf_temp, 'display_connection')) ?
+          $conf_temp['display_connection']
+          : (test_conf($ec_conf, $ec_conf_index['display_connection'],
+             'display_connection')) ?
+            $ec_conf[$ec_conf_index['display_connection']]
+            : '1',
+      $ec_conf_index['simple_mode_on'] =>
+        ($simple_mode_on) ? '1' : '0',
+      $ec_conf_index['display_full_button'] =>
+        ($simple_mode_on and test_conf($conf_temp, 'display_full_button')) ?
+          $conf_temp['display_full_button']
+          : (test_conf($ec_conf, $ec_conf_index['display_full_button'],
+             'display_full_button')) ?
+            $ec_conf[$ec_conf_index['display_full_button']]
+            : '1',
+    );
+    change_ec_conf('activated', $u); // write in the DB
+  }
+  else { // $simple_mode_on is true ; check $conf values for Event Cats
+    foreach ($ec_conf_possible_values as $key => $val)
+     if (test_conf($conf_temp, $key))
+      change_ec_conf($key, $conf_temp[$key]);
+  }
+  unset($conf_temp);
 }
 // now :
 //   _ the number of parameters is the same in the DB as the number of
-//     default parameters;
+//     possible parameters;
 //   _ the parameters have the default values if needed;
 //   _ the plugin shows it is active if it is the case;
Index: /extensions/event_cats/main.inc.php
===================================================================
--- /extensions/event_cats/main.inc.php	(revision 7083)
+++ /extensions/event_cats/main.inc.php	(revision 7084)
@@ -32,5 +32,5 @@
 // +-----------------------------------------------------------------------+
 
-// Keeps file coded in UTF-8 without BOM : é
+// Keeps file coded in UTF-8 without BOM: é
 
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
@@ -43,5 +43,5 @@
 
 define( // -------------------------------------------------------------------
-  'EVNTCATS_INFO_VERSION', // VERSION HISTORY :
+  'EVNTCATS_INFO_VERSION', // VERSION HISTORY:
    '1.2.3' // Re-fix bug 1432 :-/ ...
 // '2.1.0' // When done, will simplfy and allow EC management from categories
@@ -50,14 +50,14 @@
 // '1.2.1' // Improve EN translation thanks to Tosca
 // '1.2.0' // Add feature 1335, Possibility to display the 'Connection'
-//         // link in identification block menu for generic users ;
+//         // link in identification block menu for generic users;
 //         // finish (yes !) english translation
 // '1.1.5' // Fix bugs 1324 and 1325
 // '1.1.4' // Improve help banner
-// '1.1.3' // Better help banner management ; finalize banner texts
-// '1.1.2' // Better help banner example : some examples
-// '1.1.1' // Better help banner example ; but still no text in it
-// '1.1.0' // First bugs (1305 and 1306) corrected ;
+// '1.1.3' // Better help banner management; finalize banner texts
+// '1.1.2' // Better help banner example: some examples
+// '1.1.1' // Better help banner example; but still no text in it
+// '1.1.0' // First bugs (1305 and 1306) corrected;
            // add newly created user/group association with cat/AP (was
-           // forgotten) ; begin help banner
+           // forgotten); begin help banner
 // '1.0.0' // Conception version
 ); // ------------------------------------------------------------------------
@@ -103,5 +103,5 @@
   return (
    $help_content = (is_admin() and $page == 'help') ?
-    load_language($page.'.html', EVNTCATS_PATH, array('return' => true)) : false
+    load_language($page.'.html',EVNTCATS_PATH,array('return' => true)) : false
   ) ? $popup_help_content.$help_content : $popup_help_content;
 }
@@ -112,6 +112,6 @@
  *
  * auto_log_user()
- * the function uses the value of the argument "autolog" of the posted URL, as a code
- * to know which username has to be logged in.
+ * the function uses the value of the argument "autolog" of the posted URL,
+ * as a code to know which username has to be logged in.
  *
  * @param no parameter
@@ -128,5 +128,5 @@
   $ec_img = NULL;
   
-  if (isset($_GET['autolog']) and (read_ec_conf('activated') == 1)) {
+  if (isset($_GET['autolog']) and (read_ec_conf('activated') == '1')) {
     if (!is_a_guest()) {
       $url = '';
@@ -166,5 +166,5 @@
             if (isset($ec_img)) {
               if (ec_image_exists($ec_cat, $ec_img)) {
-                redirect(PHPWG_ROOT_PATH.'picture.php?/'.$ec_img.'/category/'.$ec_cat);
+       redirect(PHPWG_ROOT_PATH.'picture.php?/'.$ec_img.'/category/'.$ec_cat);
               }
             }
@@ -230,52 +230,60 @@
   global $user;
 
-  if (!is_a_guest() and !is_admin()) if (
-    read_ec_conf('dup_allow') == '1' or (
-      read_ec_conf('dup_allow') == '2' and
-      dup_allowed($user['id'])
-    )
-  ) {
-    // User access
-    $result = pwg_query("
-      SELECT `cat_id`
-      FROM `".USER_ACCESS_TABLE."`
-      WHERE `user_id` = ".$user['id'].";
-    ");
-    $insert = array();
-    while ($row = pwg_db_fetch_assoc($result))
-     $insert[] = "(".$new_user['id'].",".$row['cat_id'].")";
-    if (!empty($insert)) pwg_query("
-      INSERT INTO `".USER_ACCESS_TABLE."`
-      VALUES ".implode(',', $insert).";
-    ");
-
-    // User groups
-    $result = pwg_query("
-      SELECT `group_id`
-      FROM `".USER_GROUP_TABLE."`
-      WHERE `user_id` = ".$user['id'].";
-    ");
-    $insert = array();
-    while ($row = pwg_db_fetch_assoc($result))
-     $insert[] = "(".$new_user['id'].",".$row['group_id'].")";
-    if (!empty($insert)) pwg_query("
-      INSERT INTO `".USER_GROUP_TABLE."`
-      VALUES ".implode(',', $insert).";
-    ");
-
-    // User infos
-    $result = pwg_query("
-      SELECT `level`
-      FROM `".USER_INFOS_TABLE."`
-      WHERE `user_id` = ".$user['id'].";
-    ");
-    $insert = array();
-    while ($row = pwg_db_fetch_assoc($result))
-     $insert[] = "(".$new_user['id'].",".$row['level'].")";
-    if (!empty($insert)) pwg_query("
-      UPDATE `".USER_INFOS_TABLE."`
-      SET `level` = ".$user['level']."
-      WHERE `user_id` = ".$new_user['id'].";
-    ");
+  if (read_ec_conf('activated') == '1') {
+    if (
+      !is_a_guest() and !is_admin() and (
+        read_ec_conf('dup_allow') == '1' or (
+          read_ec_conf('dup_allow') == '2' and (
+            dup_allowed($user['id']) or (
+              read_ec_conf('simple_mode_on') == '1' and
+              is_generic()
+            )
+          )
+        )
+      )
+    ) {
+      // User access
+      $result = pwg_query("
+        SELECT `cat_id`
+        FROM `".USER_ACCESS_TABLE."`
+        WHERE `user_id` = ".$user['id'].";
+      ");
+      $insert = array();
+      while ($row = pwg_db_fetch_assoc($result))
+       $insert[] = "(".$new_user['id'].",".$row['cat_id'].")";
+      if (!empty($insert)) pwg_query("
+        INSERT INTO `".USER_ACCESS_TABLE."`
+        VALUES ".implode(',', $insert).";
+      ");
+
+      // User groups
+      $result = pwg_query("
+        SELECT `group_id`
+        FROM `".USER_GROUP_TABLE."`
+        WHERE `user_id` = ".$user['id'].";
+      ");
+      $insert = array();
+      while ($row = pwg_db_fetch_assoc($result))
+       $insert[] = "(".$new_user['id'].",".$row['group_id'].")";
+      if (!empty($insert)) pwg_query("
+        INSERT INTO `".USER_GROUP_TABLE."`
+        VALUES ".implode(',', $insert).";
+      ");
+
+      // User infos
+      $result = pwg_query("
+        SELECT `level`
+        FROM `".USER_INFOS_TABLE."`
+        WHERE `user_id` = ".$user['id'].";
+      ");
+      $insert = array();
+      while ($row = pwg_db_fetch_assoc($result))
+       $insert[] = "(".$new_user['id'].",".$row['level'].")";
+      if (!empty($insert)) pwg_query("
+        UPDATE `".USER_INFOS_TABLE."`
+        SET `level` = ".$user['level']."
+        WHERE `user_id` = ".$new_user['id'].";
+      ");
+    }
   }
 }
@@ -313,38 +321,46 @@
   global $lang, $template, $user;
   
-  if (version_compare(PHPWG_VERSION, '2.1.0', '<')) {
-    // Makes the "quick connect" fieldset able to redirect to current page
-    // after user identification, just as does the "connection" link.
-    $template->assign(array('U_REDIRECT' => $_SERVER['REQUEST_URI']));
-    $template->set_prefilter('menubar', 'ec_duplicate_prefilter');
-  }
-  
-  // Adds duplication link, if needed
-  if (!is_admin() and !is_a_guest()) if (
-    read_ec_conf('dup_allow') == '1' or (
-      read_ec_conf('dup_allow') == '2' and
-      dup_allowed($user['id'])
-    )
-  ) {
-    $template->assign('U_REGISTER', get_root_url().'register.php');
+  if (read_ec_conf('activated') == '1') {
+    if (version_compare(PHPWG_VERSION, '2.1.0', '<')) {
+      // Makes the "quick connect" fieldset able to redirect to current page
+      // after user identification, just as does the "connection" link.
+      $template->assign(array('U_REDIRECT' => $_SERVER['REQUEST_URI']));
+      $template->set_prefilter('menubar', 'ec_duplicate_prefilter');
+    }
+    
+    // Add duplication link, if needed
     if (
-      read_ec_conf('duplic_display') == '1' or (
-        read_ec_conf('duplic_display') == '2' and
-        !is_generic()
+      !is_admin() and !is_a_guest() and (
+        read_ec_conf('dup_allow') == '1' or (
+          read_ec_conf('dup_allow') == '2' and (
+            dup_allowed($user['id']) or (
+              read_ec_conf('simple_mode_on') == '1' and
+              is_generic()
+            )
+          )
+        )
       )
     ) {
-      $lang['Register'] = $lang['Duplicate'];
-      $lang['Create a new account'] =
-       $lang['Create a new account with same properties'];
-    }
-  }
-  
-  // Adds connection link, if needed
-  if (read_ec_conf('display_connection') == '1' and is_generic()) {
-    // Adds connection link
-    $template->assign(
-      'U_LOGIN',
-      get_root_url().'identification.php?redirect='.$_SERVER['REQUEST_URI']
-    );
+      $template->assign('U_REGISTER', get_root_url().'register.php');
+      if (
+        read_ec_conf('duplic_display') == '1' or (
+          read_ec_conf('duplic_display') == '2' and
+          !is_generic()
+        )
+      ) {
+        $lang['Register'] = $lang['Duplicate'];
+        $lang['Create a new account'] =
+         $lang['Create a new account with same properties'];
+      }
+    }
+    
+    // Adds connection link, if needed
+    if (read_ec_conf('display_connection') == '1' and is_generic()) {
+      // Adds connection link
+      $template->assign(
+        'U_LOGIN',
+        get_root_url().'identification.php?redirect='.$_SERVER['REQUEST_URI']
+      );
+    }
   }
 }
Index: /extensions/event_cats/maintain.inc.php
===================================================================
--- /extensions/event_cats/maintain.inc.php	(revision 7083)
+++ /extensions/event_cats/maintain.inc.php	(revision 7084)
@@ -23,8 +23,8 @@
 // +-----------------------------------------------------------------------+
 
-// Keeps file coded in UTF-8 without BOM : é
+// Keeps file coded in UTF-8 without BOM: é
 
 // ***********************************************************************
-// ** maintain.inc.php : Installation page for Piwigo plugin Event Cats **
+// ** maintain.inc.php: Installation page for Piwigo plugin Event Cats  **
 // ***********************************************************************
 
@@ -42,5 +42,7 @@
   global $prefixeTable;
 
-	pwg_query("DELETE FROM `".CONFIG_TABLE."` WHERE `param` = 'event_cats' LIMIT 1;");
+	pwg_query("
+   DELETE IGNORE FROM `".CONFIG_TABLE."` WHERE `param` = 'event_cats' LIMIT 1;
+  ");
 	return pwg_query('DROP TABLE IF EXISTS `'.$prefixeTable.'event_cats`;');
 }
@@ -72,49 +74,50 @@
 
 /*
-Explanations on table structure :
+Explanations on table structure:
 
-code    : the code used as "autolog" argument. If thie code provided by the
-          visitor does not exist in the table, the administrator can choose
-          whether the visitor is redirected to the home page (nothing
-          happens) or to the "access denied" page ;
-user_id : the account concerned in following values ;
-action  : the action to perform :
-   ec_nok : code disabled : account not logged in, visitor (guest) redirected
-            to an explaining Additional Page (arg2 field). If Additional Page
-            plugin is not activated, redirection to the "access denied" page ;
-   ec_ok  : code OK, account logged in. Redirection depends on arg1 and arg2
-            values. There are four cases :
-     arg1 and arg2 are both NULL : home page ;
-     arg1 not NULL and arg2 NULL : category ;
-     arg1 NULL and arg2 not NULL : Additional Page ;
-     arg1 and arg2 both not NULL : Image page.
-            If arg1 is a valid category id, and arg2 is not a valid image id,
-            redirection to category. In all other cases where the arg1 or arg2
-            is not valid, redirection to home page.
-arg1    : (described above) ;
-arg2    : (described above) ;
-forced  : allows the administrator to impose that, for certain codes, the
-          settings specified in the database ("action", "arg1", "arg2") are
-          applied, whatever can be the arguments given in the URL.
+code   : the code used as "autolog" argument. If thie code provided by the
+         visitor does not exist in the table, the administrator can choose
+         whether the visitor is redirected to the home page (nothing
+         happens) or to the "access denied" page;
+user_id: the account concerned in following values;
+action : the action to perform:
+   ec_nok: code disabled: account not logged in, visitor (guest) redirected
+           to an explaining Additional Page (arg2 field). If Additional Page
+           plugin is not activated, redirection to the "access denied" page;
+   ec_ok : code OK, account logged in. Redirection depends on arg1 and arg2
+           values. There are four cases:
+     arg1 and arg2 are both NULL: home page;
+     arg1 not NULL and arg2 NULL: category;
+     arg1 NULL and arg2 not NULL: Additional Page;
+     arg1 and arg2 both not NULL: Image page.
+           If arg1 is a valid category id, and arg2 is not a valid image id,
+           redirection to category. In all other cases where the arg1 or arg2
+           is not valid, redirection to home page.
+arg1   : (described above);
+arg2   : (described above);
+forced : allows the administrator to impose that, for certain codes, the
+         settings specified in the database ("action", "arg1", "arg2") are
+         applied, whatever can be the arguments given in the URL;
+comment: a reminder for the webmaster.
            
-* As a precision :
+* As a precision:
     in the PHP code, the "action" can also have the following values, so to
-    display accurate messages in the admin page :
-  ec_nok_action_pb   : the same "code" is used in more than one entries in the
-                       DB (which is allowed) and is not always associated to
-                       the same action ('ec_ok' in one or more entries, and
-                       'ec_nok' in one or more other entries). This is
-                       confusing and makes impossible to log in using this
-                       code ;
-  ec_nok_userid_pb   : the same "code" is used in more than one entries in the
-                       DB (which is allowed) and is not always associated to
-                       the same user id. This is confusing and makes
-                       impossible to log in using this code ;
-  ec_nok_userid_miss : the user id associated to this code does not exist in
-                       the user ids table ;
-  ec_nok_ap_pb       : not valid Additional Page id -> access denied ;
-  ec_ok_ap_pb        : not valid Additional Page id -> home page ;
-  ec_ok_cat_pb       : not valid category id -> home page ;
-  ec_ok_img_pb       : not valid image id -> category page ;
+    display accurate messages in the admin page:
+  ec_nok_action_pb  : the same "code" is used in more than one entries in the
+                      DB (which is allowed) and is not always associated to
+                      the same action ('ec_ok' in one or more entries, and
+                      'ec_nok' in one or more other entries). This is
+                      confusing and makes impossible to log in using this
+                      code;
+  ec_nok_userid_pb  : the same "code" is used in more than one entries in the
+                      DB (which is allowed) and is not always associated to
+                      the same user id. This is confusing and makes
+                      impossible to log in using this code;
+  ec_nok_userid_miss: the user id associated to this code does not exist in
+                      the user ids table;
+  ec_nok_ap_pb      : not valid Additional Page id -> access denied;
+  ec_ok_ap_pb       : not valid Additional Page id -> home page;
+  ec_ok_cat_pb      : not valid category id -> home page;
+  ec_ok_img_pb      : not valid image id -> category page;
 
 _ the two main fields are "user_id" and "code", as the main purpose of the
@@ -124,12 +127,12 @@
 _ though, even if "action", "user_id" and "code" are important, all of them
   can be omitted (thus can be NULL), and both "user_id" and "code" can be
-  repeated (thus are not UNIQUE). This because :
+  repeated (thus are not UNIQUE). This because:
   _ the same code can automatically log in ("autolog") the same account
     following several ways, depending on "cat", "img", and "ap" arguments of
-    the URL ; and thus different ways can be stored in the DB ;
+    the URL; and thus different ways can be stored in the DB;
   _ a "disabled" code (the user tries to "autolog", but (s)he's not allowed
-    to) does not need a corresponding "user_id", thus "user_id" can be NULL ;
+    to) does not need a corresponding "user_id", thus "user_id" can be NULL;
   _ "user_id" field is used to store groups ids when "code" is NULL, to
-    identify groups authorized to duplication ;
+    identify groups authorized to duplication;
 _ "code" does not have the MySQL UNIQUE attribute, but it has to be unique
   when the "forced" Event Cats parameter is true, which is the case when this
