Index: extensions/event_cats/admin/duplication.inc.php
===================================================================
--- extensions/event_cats/admin/duplication.inc.php	(revision 4247)
+++ extensions/event_cats/admin/duplication.inc.php	(revision 4263)
@@ -1,135 +1,7 @@
 <?php
-
-$t = read_ec_conf('reg_display');
-if ($t == '0') $reg_display = array('0', '');
-else $reg_display = explode(';', $t);
-
-$template->assign('reg_display', $reg_display);
-$template->assign('ec_conf', $ec_conf);
 
 
 
-
-
-
-// A lot of below code has simply been copied-pasted from file cat_perm.php .
-// Many thanks to people who wrote it !
-
-// +-----------------------------------------------------------------------+
-// |                          form construction                            |
-// +-----------------------------------------------------------------------+
-
-// groups denied are the groups not granted. So we need to find all groups
-// minus groups granted to find groups denied.
-
-$groups = array();
-
-$query = '
-SELECT id, name
-  FROM '.GROUPS_TABLE.'
-  ORDER BY name ASC
-;';
-$groups = simple_hash_from_query($query, 'id', 'name');
-$template->assign('all_groups', $groups);
-
-// groups granted to access the category
-$query = "
-SELECT `arg1`
-  FROM ".EVNTCATS_TABLE."
-  WHERE `code` IS NULL
-    AND `arg1` IS NOT NULL
-;";
-$group_granted_ids = array_from_query($query, 'arg1');
-$group_granted_ids = order_by_name($group_granted_ids, $groups);
-$template->assign('group_granted_ids', $group_granted_ids);
-
-
-// groups denied
-$template->assign('group_denied_ids',
-    order_by_name(array_diff(array_keys($groups), $group_granted_ids), $groups)
-  );
-
-// users...
-$users = array();
-
-$query = "
-SELECT ".$conf['user_fields']['id']." AS id,
-       ".$conf['user_fields']['username']." AS username
-  FROM ".USERS_TABLE."
-;";
-$users = simple_hash_from_query($query, 'id', 'username');
-$template->assign('all_users', $users);
-
-
-$query = "
-SELECT `arg2`
-  FROM ".EVNTCATS_TABLE."
-  WHERE `code` IS NULL
-    AND `arg2` IS NOT NULL
-;";
-$user_granted_direct_ids = array_from_query($query, 'arg2');
-$user_granted_direct_ids = order_by_name($user_granted_direct_ids, $users);
-$template->assign('user_granted_direct_ids', $user_granted_direct_ids);
-
-
-
-$user_granted_indirect_ids = array();
-if (count($group_granted_ids) > 0)
-{
-  $granted_groups = array();
-
-  $query = "
-SELECT user_id, group_id
-  FROM ".USER_GROUP_TABLE."
-  WHERE group_id IN (".implode(',', $group_granted_ids).") 
-";
-  $result = pwg_query($query);
-  while ($row = mysql_fetch_array($result))
-  {
-    if (!isset($granted_groups[$row['group_id']]))
-    {
-      $granted_groups[$row['group_id']] = array();
-    }
-    array_push($granted_groups[$row['group_id']], $row['user_id']);
-  }
-
-  $user_granted_by_group_ids = array();
-
-  foreach ($granted_groups as $group_users)
-  {
-    $user_granted_by_group_ids = array_merge($user_granted_by_group_ids,
-                                             $group_users);
-  }
-  $user_granted_by_group_ids = array_unique($user_granted_by_group_ids);
-  
-  
-  $user_granted_indirect_ids = array_diff($user_granted_by_group_ids,
-                                          $user_granted_direct_ids);
-  $user_granted_indirect_ids = 
-    order_by_name($user_granted_indirect_ids, $users);  
-  foreach ($user_granted_indirect_ids as $user_id)
-  {
-    foreach ($granted_groups as $group_id => $group_users)
-    {
-      if (in_array($user_id, $group_users))
-      {
-        $template->append(
-          'user_granted_indirects',
-          array(
-            'USER'=>$users[$user_id],
-            'GROUP'=>$groups[$group_id]
-            )
-          );
-        break;
-      }
-    }
-  }
-}
-
-$user_denied_ids = array_diff(array_keys($users),
-                              $user_granted_indirect_ids,
-                              $user_granted_direct_ids);
-$user_denied_ids = order_by_name($user_denied_ids, $users);
-$template->assign('user_denied_ids', $user_denied_ids);
+build_dup_arrays(true);
 
 
Index: extensions/event_cats/admin/template/autolog_new.js
===================================================================
--- extensions/event_cats/admin/template/autolog_new.js	(revision 4247)
+++ extensions/event_cats/admin/template/autolog_new.js	(revision 4263)
@@ -511,12 +511,6 @@
    && ec_old_new_psd_text != ''
    && ec_selected_user == 'ec_sel_user_new'
-  ) {
-    de('ec_in_up_pwd_warn1').innerHTML = ec_JS_message['ec_new_pwd_gen1'];
-    de('ec_in_up_pwd_warn2').innerHTML = ec_JS_message['ec_new_pwd_gen2'];
-  }
-  else {
-    de('ec_in_up_pwd_warn1').innerHTML = '';
-    de('ec_in_up_pwd_warn2').innerHTML = '';
-  }
+  ) de('ec_in_up_pwd_warn').innerHTML = ec_JS_message['ec_new_pwd_gen'];
+  else de('ec_in_up_pwd_warn').innerHTML = '';
 }
 
@@ -701,6 +695,5 @@
   de('ec_in_up_grp_txt_id').value                 = '';
   de('ec_in_up_newgroup_id').checked              = '';
-  de('ec_in_up_pwd_warn1').innerHTML              = '';
-  de('ec_in_up_pwd_warn2').innerHTML              = '';
+  de('ec_in_up_pwd_warn').innerHTML               = '';
   de('ec_in_up_aps_id').selectedIndex             = '-1';
   de('ec_in_up_cats_id').selectedIndex            = '-1';
Index: extensions/event_cats/admin/template/autolog_new.tpl
===================================================================
--- extensions/event_cats/admin/template/autolog_new.tpl	(revision 4247)
+++ extensions/event_cats/admin/template/autolog_new.tpl	(revision 4263)
@@ -126,6 +126,5 @@
         {'ec_up_code_lbl_user'|@translate}<br>
         <br>
-        <span style = "font-weight:bold; color:red;" id = "ec_in_up_pwd_warn1">&nbsp;</span><br>
-        <span style = "font-weight:bold; color:red;" id = "ec_in_up_pwd_warn2">&nbsp;</span>
+        <span style = "font-weight:bold; color:red;" id = "ec_in_up_pwd_warn">&nbsp;</span><br>
       </td>
       <td>
@@ -276,6 +275,5 @@
   ec_JS_message['ec_act_cat_miss']        = "{'ec_act_cat_miss'|@translate|@escape:javascript}";
   ec_JS_message['ec_act_img_miss']        = "{'ec_act_img_miss'|@translate|@escape:javascript}";
-  ec_JS_message['ec_new_pwd_gen1']        = "{'ec_new_pwd_gen1'|@translate|@escape:javascript}";
-  ec_JS_message['ec_new_pwd_gen2']        = "{'ec_new_pwd_gen2'|@translate|@escape:javascript}";
+  ec_JS_message['ec_new_pwd_gen']         = "{'ec_new_pwd_gen'|@translate|@escape:javascript}";
   ec_JS_message['ec_act_entry_miss']      = "{'ec_act_entry_miss'|@translate|@escape:javascript}";
   ec_JS_message['ec_confirm_force']       = "{'ec_confirm_force'|@translate|@escape:javascript}";
Index: extensions/event_cats/admin/template/config.tpl
===================================================================
--- extensions/event_cats/admin/template/config.tpl	(revision 4247)
+++ extensions/event_cats/admin/template/config.tpl	(revision 4263)
@@ -13,5 +13,5 @@
   ec_JS_message['ec_gen_user_act_miss'] = "{'ec_gen_user_act_miss'|@translate|@escape:javascript}";
   ec_JS_message['ec_act_cat_miss']      = "{'ec_act_cat_miss'|@translate|@escape:javascript}";
-  ec_JS_message['ec_new_pwd_gen1']       = "{'ec_new_pwd_gen1'|@translate|@escape:javascript}";
+  ec_JS_message['ec_new_pwd_gen']       = "{'ec_new_pwd_gen'|@translate|@escape:javascript}";
   ec_JS_message['ec_up_code_lbl_home']  = "{'ec_up_code_lbl_home'|@translate}";
   ec_init();
Index: extensions/event_cats/admin/template/duplication.tpl
===================================================================
--- extensions/event_cats/admin/template/duplication.tpl	(revision 4247)
+++ extensions/event_cats/admin/template/duplication.tpl	(revision 4263)
@@ -6,8 +6,8 @@
 <p>Bientôt disponible :-] !</p>
 
-<!-- Aknowledgement ------------------------------------------------------
-A lot of below code has simply been copied-pasted from file cat_perm.tpl .
-Many thanks to people who wrote it !
-------------------------------------------------------------------------->
+<!-- Aknowledgement ----------------------------------------------------------
+| A lot of below code has simply been copied-pasted from file cat_perm.tpl . |
+| Many thanks to people who wrote it !                                       |
+----------------------------------------------------------------------------->
 
 {* <!-- Duplication configuration parameters --> *}
@@ -18,5 +18,5 @@
       <tr>
         <td>
-          <span style = "font-weight:bold;">{'ec_duplication_allowance'|@translate}</span>
+          <span style = "font-weight:bold;">{'ec_duplication_allowance'|@translate}&nbsp;&nbsp;</span>
         </td>
         <td>
@@ -28,31 +28,21 @@
             <input type = "radio" name = "ec_dup_conf" id = "ec_dup_conf_group_id" />
             {'ec_dup_allowance_group'|@translate}
-          </label><br>
+          </label><br> {* <!--
+          <label for = "ec_dup_conf_gen_id">
+            <input type = "radio" name = "ec_dup_conf" id = "ec_dup_conf_gen_id" />
+            {'ec_dup_allowance_gen'|@translate}
+          </label><br> --> *}
           <label for = "ec_dup_conf_all_id">
             <input type = "radio" name = "ec_dup_conf" id = "ec_dup_conf_all_id" />
             {'ec_dup_allowance_all'|@translate}
-          </label><br>
-        </td>
-        <td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td>
-        <td>
-          <span style = "font-weight:bold;">{'ec_duplication_display'|@translate}</span>
-        </td>
-        <td>
-          <label for = "ec_dup_disp_normal_id">
-            <input type = "radio" name = "ec_dup_disp" id = "ec_dup_disp_normal_id" />
-            {'ec_dup_display_normal'|@translate}{if $reg_display.0 != '0'} ("{$reg_display.1}"){/if}
-          </label><br>
-          <label for = "ec_dup_disp_dup_id">
-            <input type = "radio" name = "ec_dup_disp" id = "ec_dup_disp_dup_id" />
-            {'ec_dup_display_dup'|@translate} ("{'ec_duplication'|@translate}")
-          </label><br>
+          </label>
         </td>
       </tr>
     </table>
-    <input class = "submit" type = "submit" name = "ec_duplic_conf_submit" value = "{'ec_dup_conf_submit_lbl'|@translate}" />
+    <input class = "submit" type = "submit" name = "ec_duplic_conf_submit" value = "{'ec_dup_conf_sbmt_lbl'|@translate}" />
   </fieldset>
 </form>
 
-{* <!-- Duplication settings by groups / user ids --> *}
+{* <!-- Duplication settings by groups / types / user ids --> *}
 <form action = "" method = "post" name = "ec_duplic_set" id="categoryPermissions">
 
@@ -60,5 +50,5 @@
 
   <fieldset>
-    <legend>{'Permission granted'|@translate}</legend>
+    <legend>{'ec_duplic_ok'|@translate}</legend>
     <ul>
       {foreach from=$group_granted_ids item=id}
@@ -66,9 +56,9 @@
       {/foreach}
     </ul>
-    <input class = "submit" type = "submit" name = "deny_groups_submit" value = "{'Deny selected groups'|@translate}" />
+    <input class = "submit" type = "submit" name = "deny_groups_submit" value = "{'ec_dup_grp_ok_sbmt_lbl'|@translate}" />
   </fieldset>
 
   <fieldset>
-    <legend>{'Permission denied'|@translate}</legend>
+    <legend>{'ec_duplic_nok'|@translate}</legend>
     <ul>
       {foreach from=$group_denied_ids item=id}
@@ -76,5 +66,19 @@
       {/foreach}
     </ul>
-    <input class = "submit" type = "submit" name = "grant_groups_submit" value = "{'Grant selected groups'|@translate}" />
+    <input class = "submit" type = "submit" name = "grant_groups_submit" value = "{'ec_dup_grp_nok_sbmt_lbl'|@translate}" />
+  </fieldset>
+
+  <h4>{'ec_dup_types'|@translate}</h4>
+
+  <fieldset>
+    <legend>{'ec_duplic_ok'|@translate}</legend>
+    <ul>
+      <li><label><input type = "checkbox" name = "ec_dup_types_generic_ok" value = "ec_dup_types_generic_ok_id" /> {'user_status_generic'|@translate}</label></li>
+      <br />
+      <li><label><input type = "checkbox" name = "ec_dup_types_contacts_ok" value = "ec_dup_types_contacts_ok_id" /> {'Level 1'|@translate}</label></li>
+      <li><label><input type = "checkbox" name = "ec_dup_types_friends_ok" value = "ec_dup_types_friends_ok_id" /> {'Level 2'|@translate}</label></li>
+      <li><label><input type = "checkbox" name = "ec_dup_types_family_ok" value = "ec_dup_types_family_ok_id" /> {'Level 4'|@translate}</label></li>
+    </ul>
+    <input class = "submit" type = "submit" name = "deny_users_submit" value = "{'ec_dup_typ_sbmt_lbl'|@translate}" />
   </fieldset>
 
@@ -82,5 +86,5 @@
 
   <fieldset>
-    <legend>{'Permission granted'|@translate}</legend>
+    <legend>{'ec_duplic_ok'|@translate}</legend>
     <ul>
       {foreach from=$user_granted_direct_ids item=id}
@@ -88,9 +92,9 @@
       {/foreach}
     </ul>
-    <input class = "submit" type = "submit" name = "deny_users_submit" value = "{'Deny selected users'|@translate}" />
+    <input class = "submit" type = "submit" name = "deny_users_submit" value = "{'ec_dup_usr_ok_sbmt_lbl'|@translate}" />
   </fieldset>
 
   <fieldset>
-    <legend>{'Permission granted thanks to a group'|@translate}</legend>
+    <legend>{'ec_duplic_ok_groups'|@translate}</legend>
     {if isset($user_granted_indirects) }
     <ul>
@@ -103,5 +107,5 @@
 
   <fieldset>
-    <legend>{'Permission denied'|@translate}</legend>
+    <legend>{'ec_duplic_nok'|@translate}</legend>
     <ul>
       {foreach from=$user_denied_ids item=id}
@@ -109,5 +113,5 @@
       {/foreach}
     </ul>
-    <input class = "submit" type = "submit" name = "grant_users_submit" value = "{'Grant selected users'|@translate}" />
+    <input class = "submit" type = "submit" name = "grant_users_submit" value = "{'ec_dup_usr_nok_sbmt_lbl'|@translate}" />
   </fieldset>
 
@@ -123,5 +127,5 @@
   ec_JS_message['ec_gen_user_act_miss'] = "{'ec_gen_user_act_miss'|@translate|@escape:javascript}";
   ec_JS_message['ec_act_cat_miss']      = "{'ec_act_cat_miss'|@translate|@escape:javascript}";
-  ec_JS_message['ec_new_pwd_gen1']       = "{'ec_new_pwd_gen1'|@translate|@escape:javascript}";
+  ec_JS_message['ec_new_pwd_gen']       = "{'ec_new_pwd_gen'|@translate|@escape:javascript}";
   ec_JS_message['ec_up_code_lbl_home']  = "{'ec_up_code_lbl_home'|@translate}";
   ec_init();
Index: extensions/event_cats/include/ec_conf.inc.php
===================================================================
--- extensions/event_cats/include/ec_conf.inc.php	(revision 4247)
+++ extensions/event_cats/include/ec_conf.inc.php	(revision 4263)
@@ -40,7 +40,9 @@
     => '10',              // automatically
                           // 
-  'reg_display'           // the way the "register" link is displayed,
-    => '0',               // together with the original $lang value for this
-                          // label
+  'duplic_gen'            // whether Generic accounts allow to be duplicated
+    => '0',               //
+                          // 
+  'duplic_type'           // the kind of account type (Contacts, Friends,
+    => '0',               // Family) allowed to duplicate account
                           // 
   'howto'                 // whether the small aknowledgement message has
@@ -78,5 +80,5 @@
 if (!$v) {
   $ec_conf = array_values($ec_conf_default);
-  change_ec_conf('activated', $u);
+  change_ec_conf('activated', $u); // writes in the DB
 }
 // now :
Index: extensions/event_cats/include/evntcats_main_funcs.inc.php
===================================================================
--- extensions/event_cats/include/evntcats_main_funcs.inc.php	(revision 4247)
+++ extensions/event_cats/include/evntcats_main_funcs.inc.php	(revision 4263)
@@ -33,4 +33,12 @@
 
 include_once(EVNTCATS_PATH.'include/ec_conf.inc.php');
+
+if (!isset($ec_lists)) {
+  $ec_lists               = array();
+  $ec_lists['add_pages']  = array();
+  $ec_lists['categories'] = array();
+  $ec_lists['user_ids']   = array();
+  $ec_lists['ec_table']   = array();
+}
 
 // +-----------------------------------------------------------------------+
@@ -163,4 +171,25 @@
 
 /*
+ * build_ec_addp()
+ * builds $ec_lists['add_pages'].
+ *
+ * @param
+ *   (no parameter)
+ * @return
+ *   (no return value)
+ */
+function build_ec_addp() {
+  global $ec_lists, $ec_ap_ok;
+  if ($ec_ap_ok) {
+    $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];
+    }
+  }
+}
+
+/*
  * build_ec_categories($dsp)
  * builds $ec_lists['categories'].
@@ -183,4 +212,25 @@
 
 /*
+ * build_ec_userids()
+ * builds $ec_lists['user_ids'].
+ *
+ * @param
+ *   (no parameter)
+ * @return
+ *   (no return value)
+ */
+function build_ec_userids() {
+  global $ec_lists, $conf;
+  $ec_lists['user_ids'] = simple_hash_from_query("
+    SELECT
+      ".$conf['user_fields']['id']." AS id,
+      ".$conf['user_fields']['username']." AS username
+    FROM `".USERS_TABLE."`
+    WHERE id > 2;",
+    'id', 'username'
+  );
+}
+
+/*
  * build_ec_table()
  * builds a table showing the content of the <pwg>_event_cats database table,
@@ -195,6 +245,4 @@
 function build_ec_table() {
   global $ec_lists, $ec_ap_ok;
-  
-  $ec_lists['ec_table'] = array();
   
   $q = pwg_query("
@@ -276,16 +324,6 @@
   global $ec_ap_ok, $template, $ec_lists, $conf;
   
-  $ec_lists = array();
-
   // Construction of $ec_lists['add_pages'] array var
-  $ec_lists['add_pages'] = array();
-  if ($ec_ap_ok) {
-    $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];
-    }
-  }
+  build_ec_addp();
   
   // Construction of $ec_lists['categories'] array var
@@ -293,14 +331,5 @@
   
   // Construction of $ec_lists['user_ids'] array var
-  $ec_lists['user_ids'] = array();
-  $q = pwg_query("
-    SELECT
-      ".$conf['user_fields']['id']." AS id,
-      ".$conf['user_fields']['username']." AS username
-    FROM `".USERS_TABLE."`
-    WHERE id > 2
-  ");
-  while ($r = mysql_fetch_assoc($q))
-   $ec_lists['user_ids'][$r['id']] = $r['username'];
+  build_ec_userids();
   
   // Construction of $ec_lists['ec_table'] array var
@@ -308,3 +337,221 @@
 }
 
+// +-----------------------------------------------------------------------+
+// | Duplication analysis functions                                        |
+// +-----------------------------------------------------------------------+
+
+/*
+ * build_dup_arrays($append_tpl = false)
+ * builds arrays telling which accounts are allowed to display a duplicate
+ * account link. Returns an array of all the user ids allowed to duplicate.
+ *
+ * @param
+ *   $append_tpl : tells if $template must be appended with built arrays
+ * @return
+ *   (no return value)
+ */
+function build_dup_arrays($append_tpl = false) {
+  global $template, $ec_lists, $conf, $ec_debug;
+  
+  if (count($ec_lists['user_ids']) == 0) build_ec_userids();
+  
+  // A lot of below code has simply been copied from file cat_perm.php .
+  // Many thanks to people who wrote it !
+  
+  $groups = simple_hash_from_query("
+    SELECT `id`, `name`
+      FROM `".GROUPS_TABLE."`
+      ORDER BY `name` ASC;
+    ",
+    'id', 'name'
+  );
+  
+  // groups granted to duplication
+  $group_granted_ids = order_by_name(
+    array_from_query("
+      SELECT `arg2`
+        FROM ".EVNTCATS_TABLE."
+        WHERE `code` IS NULL
+          AND `arg1` = '1'
+          AND `arg2` IS NOT NULL
+      ;",
+      'arg2'
+    ),
+    $groups
+  );
+  
+  // users directly granted to duplication
+  $users_granted_direct_ids = order_by_name(
+    array_from_query("
+      SELECT `arg2`
+        FROM ".EVNTCATS_TABLE."
+        WHERE `code` IS NULL
+          AND `arg1` = '2'
+          AND `arg2` IS NOT NULL
+      ;",
+      'arg2'
+    ),
+    $ec_lists['user_ids']
+  );
+  
+  // Calculate users granted to duplication thanks to belonging to a
+  // certain group (in groups, level (friends, family, contacts),
+  // or user status (generic))
+  $user_granted_ids = array();
+
+  $users_granted_thks_gen_ids = array();
+  if (read_ec_conf('duplic_gen') != '0') {
+    $users_granted_thks_gen_ids = order_by_name(
+      array_diff(
+        array_from_query("
+          SELECT `user_id`
+          FROM `".USER_INFOS_TABLE."`
+          WHERE `status` = 'generic';",
+          'user_id'
+        ),
+        $users_granted_direct_ids
+      ),
+      $ec_lists['user_ids']
+    );
+    foreach ($users_granted_thks_gen_ids as $user_id)
+     $user_granted_ids[$user_id] = l10n('user_status_generic');
+  } global $ec_debug; $ec_debug['1'] = $user_granted_ids;
+
+  $users_granted_thks_types_ids = array();
+  $c = intval(read_ec_conf('duplic_type'));
+  if ($c != 0) {
+    $t = array();
+    if (($c & 1) != 0) $t[] = '1';
+    if (($c & 2) != 0) $t[] = '2';
+    if (($c & 4) != 0) $t[] = '4';
+    if (count($t) > 0) {
+      $types = array(
+        '1' => l10n('Level 1'),
+        '2' => l10n('Level 2'),
+        '4' => l10n('Level 4'),
+      );
+      $user_granted_from_type = array();
+      $result = pwg_query("
+        SELECT `user_id`, `level`
+        FROM `".USER_INFOS_TABLE."`
+        WHERE `level` IN (".implode(',', $t).");
+      ");
+      while ($row = mysql_fetch_array($result)) {
+        if (!isset($user_granted_from_type[$row['level']])) {
+          $user_granted_from_type[$row['level']] = array();
+        }
+        $user_granted_from_type[$row['level']][] = $row['user_id'];
+      }
+      $user_granted_by_type_ids = array();
+      foreach ($user_granted_from_type as $type_users)
+       $user_granted_by_type_ids = array_merge(
+        $user_granted_by_type_ids,
+        $type_users
+       );
+      $users_granted_thks_types_ids = order_by_name(
+        array_diff(
+          array_unique($user_granted_by_type_ids),
+          $users_granted_direct_ids
+        ),
+        $ec_lists['user_ids']
+      );
+      foreach ($users_granted_thks_types_ids as $user_id)
+       foreach ($user_granted_from_type as $type_id => $type_users) {
+        if (in_array($user_id, $type_users)) {
+          $user_granted_ids[$user_id]= $types[$type_id];
+          break;
+        }
+       }
+    }
+  } $ec_debug['2'] = $user_granted_ids;
+
+  $users_granted_thks_groups_ids = array();
+  if (count($group_granted_ids) > 0) {
+    $granted_groups = array();
+
+    $result = pwg_query("
+      SELECT `user_id`, `group_id`
+      FROM `".USER_GROUP_TABLE."`
+      WHERE `group_id` IN (".implode(',', $group_granted_ids).");
+    ");
+    while ($row = mysql_fetch_array($result)) {
+      if (!isset($granted_groups[$row['group_id']])) {
+        $granted_groups[$row['group_id']] = array();
+      }
+      $granted_groups[$row['group_id']][] = $row['user_id'];
+    }
+    
+    $user_granted_by_group_ids = array();
+    
+    foreach ($granted_groups as $group_users)
+     $user_granted_by_group_ids = array_merge(
+      $user_granted_by_group_ids,
+      $group_users
+     );
+    $users_granted_thks_groups_ids = order_by_name(
+      array_diff(
+        array_unique($user_granted_by_group_ids),
+        $users_granted_direct_ids
+      ),
+      $ec_lists['user_ids']
+    );
+    foreach ($users_granted_thks_groups_ids as $user_id)
+     foreach ($granted_groups as $group_id => $group_users)
+      if (in_array($user_id, $group_users)) {
+        $user_granted_ids[$user_id]= $groups[$group_id];
+        break;
+      }
+    
+  } $ec_debug['3'] = $user_granted_ids;
+
+  if ($append_tpl) {
+    $user_denied_ids = order_by_name(
+      array_diff(
+        array_keys($ec_lists['user_ids']),
+        $users_granted_thks_gen_ids,
+        $users_granted_thks_types_ids,
+        $users_granted_thks_groups_ids,
+        $users_granted_direct_ids
+      ),
+      $ec_lists['user_ids']
+    );
+    
+    foreach ($user_granted_ids as $u => $g) $template->append(
+      'user_granted_indirects',
+      array(
+        'USER'  => $ec_lists['user_ids'][$u],
+        'GROUP' => $g
+      )
+    );
+    
+    $ec_debug['4'] = $user_granted_ids;
+    $template->assign('all_groups', $groups);
+    $template->assign('group_granted_ids', $group_granted_ids);
+    $template->assign('group_denied_ids',order_by_name(
+      array_diff(array_keys($groups), $group_granted_ids), $groups
+    ));
+    $template->assign('all_users', $ec_lists['user_ids']);
+    $template->assign('users_granted_direct_ids', $users_granted_direct_ids);
+    $template->assign('user_denied_ids', $user_denied_ids);
+  }
+   $user_granted_ids = array_merge(
+    $user_granted_ids,
+    $users_granted_direct_ids
+   );
+  return $user_granted_ids;
+}
+
+/*
+ * dup_allowed($user_id)
+ * returns true if the user_id is allowed to display a duplicate link
+ *
+ * @param
+ *   $user_id : the user_id
+ * @return
+ *   true if the user_id is allowed to display a duplicate link
+ */
+function dup_allowed($user_id) {
+  return true;
+}
+
 ?>
Index: extensions/event_cats/language/fr_FR/plugin.lang.php
===================================================================
--- extensions/event_cats/language/fr_FR/plugin.lang.php	(revision 4247)
+++ extensions/event_cats/language/fr_FR/plugin.lang.php	(revision 4263)
@@ -75,12 +75,26 @@
 $lang['ec_duplication']           = 'Dupliquer';
 $lang['ec_duplication_config']    = 'Configuration';
-$lang['ec_duplication_allowance'] = 'Autorisation de la duplication :';
-$lang['ec_dup_allowance_none']    = 'Aucun compte';
+$lang['ec_dup_types']             = 'Types d\'utilisateurs';
+$lang['ec_dup_types_generic']     = 'Génériques';
+$lang['ec_dup_types_contacts']    = 'Contacts';
+$lang['ec_dup_types_friends']     = 'Amis';
+$lang['ec_dup_types_family']      = 'Famille';
+$lang['ec_duplication_allowance'] = 'Autorisation de la duplication';
+$lang['ec_dup_allowance_none']    = 'Aucun compte';                       /*
+$lang['ec_dup_allowance_gen']     = 'Tous les comptes génériques';        */
 $lang['ec_dup_allowance_group']   = 'Sélection par groupe';
-$lang['ec_dup_allowance_all']     = 'Tous les comptes';
-$lang['ec_duplication_display']   = 'Affichage du lien de duplication :';
+$lang['ec_dup_allowance_all']     = 'Tous les comptes';                   /*
+$lang['ec_duplication_display']   = 'Affichage du lien de duplication';
 $lang['ec_dup_display_normal']    = 'Normal';
-$lang['ec_dup_display_dup']       = 'Modifié';
-$lang['ec_dup_conf_submit_lbl']   = 'Sauvegarder la configuration de la duplication';
+$lang['ec_dup_display_dup']       = 'Modifié';                            */
+$lang['ec_duplic_ok']             = 'Duplication autorisée';
+$lang['ec_duplic_ok_groups']      = 'Duplication autorisée grâce à l\'appartenance aux groupes et aux types';
+$lang['ec_duplic_nok']            = 'Duplication refusée';
+$lang['ec_dup_grp_ok_sbmt_lbl']   = 'Interdire la duplication aux groupes sélectionnés';
+$lang['ec_dup_grp_nok_sbmt_lbl']  = 'Autoriser la duplication aux groupes sélectionnés';
+$lang['ec_dup_usr_ok_sbmt_lbl']   = 'Interdire la duplication aux utilisateurs sélectionnés';
+$lang['ec_dup_usr_nok_sbmt_lbl']  = 'Autoriser la duplication aux utilisateurs sélectionnés';
+$lang['ec_dup_typ_sbmt_lbl']      = 'Sauvegarder';
+$lang['ec_dup_conf_sbmt_lbl']     = 'Sauvegarder la configuration de la duplication';
 // JS checks
 $lang['ec_confirm_test']          = "Vraiment tester le code sélectionné ?\n\rCela terminera votre session d'administration.";
@@ -93,6 +107,5 @@
 $lang['ec_act_cat_miss']          = 'Catégorie ?';
 $lang['ec_act_img_miss']          = 'L\'identifiant d\'une image doit être un nombre.';
-$lang['ec_new_pwd_gen1']          = 'Pensez à NOTER';
-$lang['ec_new_pwd_gen2']          = 'le mot de passe !';
+$lang['ec_new_pwd_gen']           = 'Pensez à NOTER<br>le mot de passe !';
 $lang['ec_submit_code_miss']      = 'Vous devez fournir un code.';
 $lang['ec_submit_code_bad']       = 'Un code doit comprendre entre 4 et 32 caractères inclus dans [a-zA-Z0-9_-].';
Index: extensions/event_cats/main.inc.php
===================================================================
--- extensions/event_cats/main.inc.php	(revision 4247)
+++ extensions/event_cats/main.inc.php	(revision 4263)
@@ -48,6 +48,4 @@
 $ec_ap_ok = defined('AP_DIR');
 
-if (!isset($ec_lists)) $ec_lists = array();
-
 include_once(EVNTCATS_PATH.'include/evntcats_main_funcs.inc.php');
 
@@ -265,10 +263,10 @@
   global $lang, $template;
   
-  if (is_admin() and read_ec_conf('reg_display') == '0')
-   change_ec_conf('reg_display', '1;'.$lang['Register']);
   if (!is_admin() and !is_a_guest()) {
     $template->assign( 'U_REGISTER', get_root_url().'register.php');
-    $lang['Create a new account'] = l10n('Duplicate account');
-    $lang['Register'] = l10n('Duplicate');
+    if (isset($lang['Duplicate account']))
+     $lang['Create a new account'] = l10n('Duplicate account');
+    if (isset($lang['Register']))
+     $lang['Register'] = l10n('Duplicate');
   }
 }
