Index: /extensions/event_cats/admin/autolog_new.inc.php
===================================================================
--- /extensions/event_cats/admin/autolog_new.inc.php	(revision 4435)
+++ /extensions/event_cats/admin/autolog_new.inc.php	(revision 4436)
@@ -58,5 +58,6 @@
   if (
     array_key_exists($_POST['ec_entry_sel'], $ec_lists['ec_table']) or
-    $_POST['ec_entry_sel'] == '-1'
+    $_POST['ec_entry_sel'] == '-1' or
+    $_POST['ec_act1'] == 'delete' // occurs when last entry is deleted
   ) {
     switch ($_POST['ec_act1']) {
@@ -69,5 +70,9 @@
       case 'create':
         $ec_default_action = $_POST['ec_act1'];
-        $ec_default_entry =  $_POST['ec_entry_sel'];
+        $ec_default_entry  = $_POST['ec_entry_sel'];
+      break;
+      case 'delete':
+        $ec_default_action = 'create';
+        $ec_default_entry  = '-1';
       break;
       default:
Index: /extensions/event_cats/admin/evntcats_admin.php
===================================================================
--- /extensions/event_cats/admin/evntcats_admin.php	(revision 4435)
+++ /extensions/event_cats/admin/evntcats_admin.php	(revision 4436)
@@ -325,5 +325,5 @@
 // +-----------------------------------------------------------------------+
 
-check_DB();
+check_DB(); $ec_debug['ec_exist_entries'] = $ec_exist_entries;
   
 if (
@@ -331,4 +331,8 @@
   read_ec_conf('dup_allow') != '2'
 ) $page['tab'] = 'config';
+
+if (!$ec_exist_entries and $page['tab'] == 'autolog_entries') $page['tab'] =
+ (read_ec_conf('dup_allow') == '2' and $dup_entries_exist) ?
+ 'duplication' : 'autolog_new';
 
 $tabsheet = new tabsheet();
Index: /extensions/event_cats/include/evntcats_admin_funcs.inc.php
===================================================================
--- /extensions/event_cats/include/evntcats_admin_funcs.inc.php	(revision 4435)
+++ /extensions/event_cats/include/evntcats_admin_funcs.inc.php	(revision 4436)
@@ -100,18 +100,8 @@
   // $_POST it uses, have already been checked.
   
-  // Check if a category id has been posted, and if yes if this category is
-  // private.
-  /* $cat_assoc_needed = (
-  ); */
-  
-  // Check if an add. p. id has been posted, and if yes if this add. p. is
-  // private.
-  /* $ap_assoc_needed = (
-  ); */
-  
   // User creation, as generic
   $ec_user_id = false;
   $page['errors'] = register_user(
-   $_POST['login'], $_POST['password'], '', false
+    $_POST['login'], $_POST['password'], '', false
   );
   if (
@@ -135,6 +125,6 @@
    $page['errors'][] = sprintf(l10n('ec_user_generic_pb'), $_POST['login']);
   
-  // New group creation if required,
-  // and association with user_id at the same time
+  // New group creation if required, and association with user_id, and if
+  // needed category or add. p., at the same time
   if (
     isset($_POST['ec_in_up_newgroup']) and
@@ -153,9 +143,9 @@
       "))) and
       $t2++ == 0 // The check is executed twice at maximum
-    )  // Cannot be executed twice
+    )
       $t4 = pwg_query("
         INSERT INTO `".GROUPS_TABLE."` (`name`, `is_default`)
         VALUES ('".$_POST['groupname']."', 'false');
-      ");
+      "); // Cannot be executed twice
     if ($t4)
      $page['infos'][] =
@@ -180,5 +170,10 @@
     // If a category id has been posted, the newly created group must be
     // allowed to navigate in this category
-    if (isset($_POST['ec_in_up_cat'])) {
+    // We are in the group creation block, thus the we know this group cannot
+    // be associated to any category
+    if (
+      isset($_POST['ec_in_up_cat']) and
+      array_key_exists($_POST['ec_in_up_cat'], $ec_lists['categories'])
+    ) {
       if (mysql_num_rows(pwg_query("
         SELECT `id`
@@ -208,7 +203,8 @@
          );
         else
-         $page['errors'][] =
-          sprintf(l10n('ec_group_create_pb'), $_POST['groupname']).' (3) : '.
-          'MySQL error '.mysql_errno().', "'.mysql_error().'"';
+         $page['errors'][] = sprintf(
+          l10n('ec_assoc_pb'),
+          $_POST['groupname'],$ec_lists['categories'][$_POST['ec_in_up_cat']]
+         ).' : MySQL error '.mysql_errno().', "'.mysql_error().'"';
       }
     }
@@ -216,20 +212,100 @@
     // If an add. p. id has been posted, the newly created group must be
     // allowed to navigate in this additional page
-    
-    /*
-    
-    
-    
-    
-    */
+    if (
+      isset($_POST['ec_in_up_aps']) and
+      array_key_exists($_POST['ec_in_up_aps'], $ec_lists['add_pages'])
+    ) {
+      $granted_groups = array();
+      $title_arr = array_from_query("
+        SELECT `title`
+        FROM `".ADD_PAGES_TABLE."`
+        WHERE `id` = ".$_POST['ec_in_up_aps'].";
+      ", 'title');
+      $t_user = (is_in($title_arr[0], '/user_id=')) ?
+       explode('/user_id=', $title_arr[0]) : array($title_arr[0]);
+      if (is_in($t_user[0], '/group_id=')) {
+        $t_group = explode('/group_id=', $t_user[0]);
+        $granted_groups = explode(',', $t_group[1]);
+      }
+      else $t_group[0] = $t_user[0];
+      if (!in_array($t3[0], $granted_groups)) {
+        $granted_groups[] = $t3[0];
+        $t_group[1] = implode(',', $granted_groups);
+        $t_user[0] = implode('/group_id=', $t_group);
+        if (pwg_query("
+          UPDATE `".ADD_PAGES_TABLE."`
+            SET `title` = '".implode('/user_id=', $t_user)."'
+            WHERE `id` = ".$_POST['ec_in_up_aps'].";
+        ") === false)
+         $page['errors'][] = sprintf(
+          l10n('ec_assoc_pb'),
+          $_POST['groupname'],$ec_lists['add_pages'][$_POST['ec_in_up_aps']]
+         ).' : MySQL error '.mysql_errno().', "'.mysql_error().'"';
+        else $page['infos'][] = sprintf(
+         l10n('ec_group_create_OK2'),
+         $_POST['groupname'],$ec_lists['add_pages'][$_POST['ec_in_up_aps']]
+        );
+      }
+    }
   }
   else {
     // If a category id has been posted, the newly created user must be
-    // allowed to navigate in this category
-    
-    // If an add. p. id has been posted, the newly created user must be
-    // allowed to navigate in this additional page => not possible to
-    // allow individually => must give a warning message ?
-    
+    // allowed to navigate in this category, if it is not the case yet
+    if (
+      isset($_POST['ec_in_up_cat']) and
+      array_key_exists($_POST['ec_in_up_cat'], $ec_lists['categories'])
+    ) {
+      $private_uppercats = array_from_query("
+        SELECT `id`
+        FROM `".CATEGORIES_TABLE."`
+        WHERE `id` IN (".
+          implode(',', get_uppercat_ids(array($_POST['ec_in_up_cat']))).
+        ")
+        AND `status` = 'private';
+      ", 'id');
+      // We must not reinsert already existing lines in user_access table
+      $granteds = array();
+      foreach ($private_uppercats as $cat_id)
+       $granteds[$cat_id] = array();
+      $result = pwg_query("
+        SELECT `user_id`, `cat_id`
+        FROM `".USER_ACCESS_TABLE."`
+        WHERE `cat_id` IN (".implode(',', $private_uppercats).")
+          AND `user_id` = '$ec_user_id';
+      ");
+      while ($row = mysql_fetch_array($result))
+       $granteds[$row['cat_id']][] = $row['user_id'];
+      $inserts = array();
+      foreach ($private_uppercats as $cat_id)
+       if (!in_array($ec_user_id, $granteds[$cat_id]))
+        $inserts[] = array(
+          'user_id' => $ec_user_id,
+          'cat_id'  => $cat_id
+        );
+      if (count($inserts) != 0) {
+        mass_inserts(USER_ACCESS_TABLE, array('user_id','cat_id'), $inserts);
+        if (mysql_errno() == 0)
+         $page['infos'][] = sprintf(
+           l10n('ec_group_create_OK2'),
+           $_POST['login'], $ec_lists['categories'][$_POST['ec_in_up_cat']]
+         );
+        else
+         $page['errors'][] = sprintf(
+          l10n('ec_assoc_pb'),
+          $_POST['login'], $ec_lists['categories'][$_POST['ec_in_up_cat']]
+         ).' : MySQL error '.mysql_errno().', "'.mysql_error().'"';
+      }
+    }
+      
+    // If an add. p. id has been posted, the newly created user should be
+    // allowed to navigate in this additional page => give a warning message
+    if (
+      isset($_POST['ec_in_up_aps']) and
+      array_key_exists($_POST['ec_in_up_aps'], $ec_lists['add_pages'])
+    ) $page['errors'][] = sprintf(
+      l10n('ec_user_access_AP'),
+      $ec_lists['add_pages'][$_POST['ec_in_up_aps']],
+      $_POST['login']
+    );
   }
   return $ec_user_id;
@@ -294,5 +370,5 @@
  */
 function ec_create_modify_entry_OK() {
-  global $page, $ec_lists, $ec_debug;
+  global $page, $ec_lists;
   
   // $_POST validity checks : action prevented in case of bad arguments
@@ -476,6 +552,5 @@
   $arg2p = ($arg2 == 'NULL') ? 'IS NULL' : ' = '.$arg2;
   $ec_user_idp = ($ec_user_id == 'NULL') ? 'IS NULL' : ' = '.$ec_user_id;
-  if (($t1 = mysql_fetch_row(pwg_query(// $q =
-  "
+  if (($t1 = mysql_fetch_row(pwg_query("
     SELECT `id`
     FROM `".EVNTCATS_TABLE."`
@@ -510,18 +585,4 @@
      return false;
   }
-  
-  $ec_debug[] = array(
-    'del_other' => $del_other,
-    'code' => $ec_code,
-    'user_id' => $ec_user_id,
-    'user_idp' => $ec_user_idp,
-    'action' => $action,
-    'arg1' => $arg1,
-    'arg2' => $arg2,
-    'arg1p' => $arg1p,
-    'arg2p' => $arg2p,
-    'forced' => $forced,
-    'comment' => $comment,
-  );
   
   // Action !
@@ -554,5 +615,5 @@
       $forced = ($forced == 'false') ? '' : l10n('ec_cnfrm_forced');
       $page['infos'][] =
-       sprintf(l10n('ec_entry_create_OK'), mysql_insert_id()).' : '.
+       sprintf(l10n('ec_entry_create_OK'), mysql_insert_id()).
        $ec_code.' => '.
        $ec_lists['user_ids'][$ec_user_id].$forced
@@ -600,4 +661,12 @@
 function ec_delete_entry_OK($ec_id) {
   global $page;
+  if (count($t = mysql_fetch_row(pwg_query("
+    SELECT `code`
+    FROM `".EVNTCATS_TABLE."`
+    WHERE `id` = $ec_id;
+  "))) == 0) {
+    $page['errors'][] = sprintf(l10n('ec_entry_dont_exist'), $ec_id);
+    return false;
+  }
   if (pwg_query("
     DELETE FROM `".EVNTCATS_TABLE."`
@@ -610,5 +679,5 @@
     return false;
   }
-  else $page['infos'][] = sprintf(l10n('ec_entry_del_ok'), $ec_id);
+  $page['infos'][] = sprintf(l10n('ec_entry_del_ok'), $ec_id, $t[0]);
   return true;
 }
Index: /extensions/event_cats/include/evntcats_main_funcs.inc.php
===================================================================
--- /extensions/event_cats/include/evntcats_main_funcs.inc.php	(revision 4435)
+++ /extensions/event_cats/include/evntcats_main_funcs.inc.php	(revision 4436)
@@ -187,10 +187,13 @@
 function build_ec_addp() {
   global $ec_lists;
+  $ec_lists['add_pages'] = array();
   if (defined('ADD_PAGES_TABLE')) {
-    $res = pwg_query("SELECT `id`, `title` FROM `".ADD_PAGES_TABLE."`");
-    while ($r = mysql_fetch_assoc($res)) {
-      $c = (is_in($r['title'], '/user_id=')) ? '/user_id=' : '/group_id=';
-      $a = explode($c ,$r['title']);
-      $ec_lists['add_pages'][$r['id']] = $a[0];
+    $res = pwg_query("SELECT `id`, `title` FROM `".ADD_PAGES_TABLE."`;");
+    while ($r = mysql_fetch_array($res)) {
+      $a = (is_in($r['title'], '/user_id=')) ?
+       explode('/user_id=' , $r['title']) : array($r['title']);
+      $b = (is_in($a[0], '/group_id=')) ?
+       explode('/group_id=' , $a[0]) : $a;
+      $ec_lists['add_pages'][$r['id']] = $b[0];
     }
   }
@@ -209,4 +212,5 @@
 function build_ec_categories($dsp) {
   global $template, $ec_lists;
+  $ec_lists['categories'] = array();
   $c = array();
   display_select_cat_wrapper("
@@ -228,4 +232,5 @@
 function build_ec_userids() {
   global $ec_lists, $conf;
+  $ec_lists['user_ids'] = array();
   $ec_lists['user_ids'] = simple_hash_from_query("
     SELECT
@@ -252,6 +257,8 @@
   global $ec_lists;
   
+  $ec_lists['ec_table'] = array();
   $q = pwg_query("
-    SELECT * FROM `".EVNTCATS_TABLE."`
+    SELECT *
+    FROM `".EVNTCATS_TABLE."`
     WHERE `code` IS NOT NULL
     ORDER BY `id`
Index: /extensions/event_cats/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/event_cats/language/fr_FR/plugin.lang.php	(revision 4435)
+++ /extensions/event_cats/language/fr_FR/plugin.lang.php	(revision 4436)
@@ -142,13 +142,12 @@
 
 // Infos
-$lang['ec_user_create_OK']         = 'Création utilisateur %s';
+$lang['ec_user_create_OK']         = 'Création utilisateur "%s"';
 $lang['ec_user_generic_OK']        = 'Utilisateur "%s" générique';
-$lang['ec_group_create_OK']        = 'Création groupe %s';
-$lang['ec_group_create_OK2']       = '%1$s associé à %2$s';
-                                 // %1$s : username ; %2$s : group
-$lang['ec_entry_create_OK']        = 'Création entrée %s';
+$lang['ec_group_create_OK']        = 'Création groupe "%s"';
+$lang['ec_group_create_OK2']       = '"%1$s" associé à "%2$s"';
+$lang['ec_entry_create_OK']        = 'Création entrée : %s';
 $lang['ec_cnfrm_forced']           = ' (affichage forcé)';
-$lang['ec_entry_modify_OK']        = 'Modification entrée %s';
-$lang['ec_entry_del_ok']           = 'Entrée %s supprimée.';
+$lang['ec_entry_modify_OK']        = 'Modification entrée "%s"';
+$lang['ec_entry_del_ok']           = 'Entrée %1$s ("%2$s") supprimée.';
 $lang['ec_config_saved']           = 'Configuration sauvegardée';
 // Errors
@@ -159,11 +158,14 @@
 $lang['ec_image_miss']             = 'image inexistante (probablement supprimée)';
 $lang['ec_add_page_miss']          = 'page Additional Pages inexistante (probablement supprimée)';
-$lang['ec_entry_del_nok']          = 'Problème avec suppression entrée %s : ';
+$lang['ec_entry_del_nok']          = 'Problème avec suppression entrée "%s" : ';
 $lang['ec_user_create_pb']         = 'Création nouvel utilisateur impossible';
-$lang['ec_user_generic_pb']        = 'Problème passage générique utilisateur %s';
-$lang['ec_group_create_pb']        = 'Création groupe %s impossible';
+$lang['ec_user_generic_pb']        = 'Problème passage générique utilisateur "%s"';
+$lang['ec_group_create_pb']        = 'Création groupe "%s" impossible';
+$lang['ec_user_access_AP']         = 'Attention à ce que la page "%1$s" soit autorisée pour l\'utilisateur "%2$s".';
 $lang['ec_entry_create_pb']        = 'Création entrée impossible';
-$lang['ec_entry_already_exists']   = 'Entrée %s déjà existante';
-$lang['ec_DB_problem']             = 'Problème d\'accès à la base (n°%s) : ';
+$lang['ec_entry_already_exists']   = 'Entrée "%s" existe déjà avec exactement la même configuration';
+$lang['ec_entry_dont_exist']       = 'Entrée %s inexistante';
+$lang['ec_assoc_pb']               = 'Association "%1$s" à "%2$s" impossible';
+$lang['ec_DB_problem']             = 'Problème d\'accès à la base (position %s) : ';
 
 // Entries table
Index: /extensions/event_cats/maintain.inc.php
===================================================================
--- /extensions/event_cats/maintain.inc.php	(revision 4435)
+++ /extensions/event_cats/maintain.inc.php	(revision 4436)
@@ -68,5 +68,5 @@
     )
     DEFAULT CHARACTER SET utf8
-    TYPE=MyISAM;
+    ENGINE=MyISAM;
   ") !== false);
 
