Index: /extensions/adult_content/charte_user.php
===================================================================
--- /extensions/adult_content/charte_user.php	(revision 9563)
+++ /extensions/adult_content/charte_user.php	(revision 9564)
@@ -12,5 +12,4 @@
    $page['body_id'] = 'adult_content_page';
    include(PHPWG_ROOT_PATH.'include/page_header.php');
-   //include(get_language_filepath('plugin.lang.php', $adult_content->plugin_path));
    load_language('plugin.lang', $adult_content->plugin_path);
 
@@ -19,39 +18,32 @@
        'PLUGIN_NAME' => $adult_content->plugin_name
        ));
+////////////lié à quoi/////	
+			$adult_content->fill_idgroups_user();
+			$adult_content->fill_idgroups_ad_c();	
 
-   if (isset($_GET['etat']) and $_GET['etat'] == 'not_defined' and !is_a_guest() )
-   {
-       $template->assign(
-         array(
-           'EXPLIC' => $lang['ac_not_def'],
-           'MAIN'  => $lang['ac_text_charte'],
-           'ETAT'  => $_GET['etat'],
-            )
-         );
-   }
-   elseif (isset($_GET['etat']) and $_GET['etat'] == 'defined' and !is_a_guest() )
-   {
-   	 $query = '
-SELECT group_id FROM '.USER_GROUP_TABLE.'
-  WHERE user_id IN (\''.$user['id'].'\')
-;';
-     $data_group = mysql_fetch_array(pwg_query($query));
-   	 $query = '
-SELECT name FROM '.GROUPS_TABLE.'
-  WHERE id IN (\''.$data_group['group_id'].'\')
-;';
-     $data_group_n = mysql_fetch_array(pwg_query($query));
-		 if ($data_group_n['name'] == '+18')
-		 {
+	if (!is_a_guest() and !$adult_content->is_in_ad_c_group())
+	{
+		 $template->assign(
+			 array(
+				 'EXPLIC' => $lang['ac_not_def'],
+				 'MAIN'  => $lang['ac_text_charte'],
+					)
+			 );
+	}
+	elseif (!is_a_guest()  and $adult_content->is_in_ad_c_group() )
+	{
+		$link=$adult_content->is_in_ad_c_group();
+		if ($link == $adult_content->idgroups_ad_c[0])
+		{
 			 $statut = $lang['ac_statut'].$lang['ac_user_text_18'];
-		 }
-		 if ($data_group_n['name'] == '16-17')
-		 {
+		}
+		if ($link ==  $adult_content->idgroups_ad_c[1])
+		{
 			 $statut = $lang['ac_statut'].$lang['ac_user_text_16'];
-		 }
-		 if ($data_group_n['name'] == 'nothing')
-		 {
+		}
+		if ($link ==  $adult_content->idgroups_ad_c[2])
+		{
 			 $statut = $lang['ac_user_no'];
-		 }
+		}
 	 
      $main = '<p>'.$statut.'</p>'
@@ -61,5 +53,4 @@
            'EXPLIC' => $lang['ac_def'],
            'MAIN'  => $main,
-           'ETAT'  => $_GET['etat'],
             )
          );
@@ -78,5 +69,7 @@
 elseif ( $_POST['groupe'] == '+18' or $_POST['groupe'] == '16-17' or $_POST['groupe'] == 'nothing')
 {
-
+////////////anciennement lié à quoi/////	
+			$adult_content->fill_idgroups_user();
+			$adult_content->fill_idgroups_ad_c();
    ////////////placer dans group////////////
       $query = '
@@ -86,11 +79,11 @@
       $data_group = mysql_fetch_array(pwg_query($query));
 	  
-      if ($_POST['etat'] == 'not_defined')
+      if (!$adult_content->is_in_ad_c_group())
 	  {
       pwg_query('INSERT INTO '.USER_GROUP_TABLE.' VALUES(\''.$user['id'].'\', \''.$data_group['id'].'\' )' );
 	  }
-      elseif ($_POST['etat'] == 'defined')
+      else
 	  {
-      pwg_query('UPDATE '.USER_GROUP_TABLE.' SET group_id=\''.$data_group['id'].'\' WHERE user_id IN (\''.$user['id'].'\')' );
+      pwg_query('UPDATE '.USER_GROUP_TABLE.' SET group_id=\''.$data_group['id'].'\' WHERE user_id IN (\''.$user['id'].'\') AND group_id IN (\''.$adult_content->is_in_ad_c_group().'\')' );
 	  }
 	  $query = '
Index: /extensions/adult_content/class.inc.php
===================================================================
--- /extensions/adult_content/class.inc.php	(revision 9563)
+++ /extensions/adult_content/class.inc.php	(revision 9564)
@@ -5,5 +5,6 @@
 {
   var $plugin_name, $plugin_path;
-  
+  var $idgroups_user = array();
+  var $idgroups_ad_c = array();// 0=+18 1=16 2=nothing
   function Adultcontent($plugin_name, $plugin_path)
   {
@@ -11,9 +12,40 @@
     $this->plugin_name = $plugin_name;
     $this->plugin_path = $plugin_path;
-    // handler
-   // $this->initialize_event_handler();
-  }
-  
-  function get_link_icon($main_link, $action)
+  }
+  function fill_idgroups_user()
+  {
+    global $user;
+
+    $query = 'SELECT group_id FROM ' . USER_GROUP_TABLE . ' WHERE user_id = ' . $user['id'] . ';';
+    $result = pwg_query($query);
+    while ($row = mysql_fetch_assoc($result))
+    {
+      array_push($this->idgroups_user, $row['group_id']);
+    }
+  }
+  function fill_idgroups_ad_c()
+  {
+    global $user;
+
+    $query = 'SELECT id FROM ' . GROUPS_TABLE . ' WHERE name IN (\'+18\', \'16-17\', \'nothing\') ORDER BY id';
+    $result = pwg_query($query);
+    while ($row = mysql_fetch_assoc($result))
+    {
+      array_push($this->idgroups_ad_c, $row['id']);
+    }
+  }
+  function is_in_ad_c_group()
+  {
+		foreach( $this->idgroups_ad_c as $id )
+		{
+			if ( in_array($id, $this->idgroups_user))
+			{
+				return $id;
+				exit; 
+			}
+		}
+		return false;
+	}
+	function get_link_icon($main_link, $action)
   {
     $link_url = add_url_params($main_link, array('ad' => $action));
@@ -24,5 +56,5 @@
   {
     global $lang;
-	load_language('plugin.lang', $this->plugin_path);
+		load_language('plugin.lang', $this->plugin_path);
   }  
   function var_template()
@@ -55,7 +87,7 @@
   {
     global $user, $template;
-	$r_theme_file=array();
-	$dir = $this->plugin_path.'template/';
-	$r_theme_file=($template->smarty->template_dir);
+		$r_theme_file=array();
+		$dir = $this->plugin_path.'template/';
+		$r_theme_file=($template->smarty->template_dir);
 		foreach( $r_theme_file as $style)
 		{
@@ -214,76 +246,44 @@
     elseif (!is_admin())
     {
-	
 ////////////lié à quoi/////	
-	 $query = '
-SELECT id FROM '.GROUPS_TABLE.'
-  WHERE name IN (\'+18\')
-;';
-     $data_18 = mysql_fetch_array(pwg_query($query));
-	 $query = '
-SELECT id FROM '.GROUPS_TABLE.'
-  WHERE name IN (\'16-17\')
-;';
-     $data_16 = mysql_fetch_array(pwg_query($query));
-	 $query = '
-SELECT id FROM '.GROUPS_TABLE.'
-  WHERE name IN (\'nothing\')
-;';
-     $data_no = mysql_fetch_array(pwg_query($query));
-	 $n_query = '
-SELECT COUNT(*) AS result FROM '.USER_GROUP_TABLE.'
-  WHERE group_id IN (\''.$data_18['id'].'\',\''.$data_16['id'].'\',\''.$data_no['id'].'\') AND user_id IN (\''.$user['id'].'\')
-;';
-      $data_user = mysql_fetch_array(pwg_query($n_query));
-	  $is_grouped = $data_user['result'];   
-
-	  if ( $is_grouped == 0 )
-	  {
-		$template->assign(
-		  array(
-			'AC_ETAT' => 'not_defined',
-			'AC_MSG' => l10n('ac_charte_user_not')
-			));
-		$menu = & $menu_ref_arr[0];
-    if (($block = $menu->get_block( 'mbAdultContent' )) != null) {
-			$block->set_title(l10n('ac_title_choose'));
-			$block->template = $this->get_template('choose.tpl');
-        }
-
-	  }
-	  else
-	  {	   
-			$query = '
-	  SELECT group_id FROM '.USER_GROUP_TABLE.'
-		WHERE user_id IN (\''.$user['id'].'\')
-	  ;';
-		   $data_group = mysql_fetch_array(pwg_query($query));
-		   $query = '
-	  SELECT name FROM '.GROUPS_TABLE.'
-		WHERE id IN (\''.$data_group['group_id'].'\')
-	  ;';
-		   $data_group_n = mysql_fetch_array(pwg_query($query));
-		   if ($data_group_n['name'] == '+18')
-		   {
-		   $statut = l10n('ac_user_text_18');
-		   }
-		   if ($data_group_n['name'] == '16-17')
-		   {
-		   $statut = l10n('ac_user_text_16');
-		   }
-		   if ($data_group_n['name'] == 'nothing')
-		   {
-		   $statut = l10n('ac_user_no_s');
-		   }
-		$template->assign(
-		  array(
-			'AC_ETAT' => 'defined',
-			'AC_MSG' => $statut.". ".l10n('ac_charte_user_def')
-			));
-		$menu = & $menu_ref_arr[0];
-    if (($block = $menu->get_block( 'mbAdultContent' )) != null) {
-			$block->set_title(l10n('ac_title_menu_statut'));
-			$block->template = $this->get_template('choose.tpl');
-		}
+			$this->fill_idgroups_user();
+			$this->fill_idgroups_ad_c();	
+
+			if ( !$this->is_in_ad_c_group() )
+			{
+				$template->assign(
+					array(
+					'AC_MSG' => l10n('ac_charte_user_not')
+					));
+				$menu = & $menu_ref_arr[0];
+				if (($block = $menu->get_block( 'mbAdultContent' )) != null) {
+					$block->set_title(l10n('ac_title_choose'));
+					$block->template = $this->get_template('choose.tpl');
+				}
+			}
+			else
+			{	   
+				$link=$this->is_in_ad_c_group();
+				if ($link == $this->idgroups_ad_c[0])
+				{
+					$statut = l10n('ac_user_text_18');
+				}
+				if ($link ==  $this->idgroups_ad_c[1])
+				{
+					$statut = l10n('ac_user_text_16');
+				}
+				if ($link ==  $this->idgroups_ad_c[2])
+				{
+					$statut = l10n('ac_user_no_s');
+				}
+				$template->assign(
+				array(
+				'AC_MSG' => $statut.". ".l10n('ac_charte_user_def')
+				));
+				$menu = & $menu_ref_arr[0];
+				if (($block = $menu->get_block( 'mbAdultContent' )) != null) {
+					$block->set_title(l10n('ac_title_menu_statut'));
+					$block->template = $this->get_template('choose.tpl');
+				}
 
 	  }
@@ -296,5 +296,5 @@
     $user_id = get_userid($_POST['login']);
     log_user( $user_id, false);
-      redirect(PHPWG_ROOT_PATH.'plugins/adult_content/charte_user.php?etat=not_defined');
+      redirect(PHPWG_ROOT_PATH.'plugins/adult_content/charte_user.php');
   } 
 }//fin class
Index: /extensions/adult_content/include/charte_user.tpl
===================================================================
--- /extensions/adult_content/include/charte_user.tpl	(revision 9563)
+++ /extensions/adult_content/include/charte_user.tpl	(revision 9564)
@@ -1,38 +1,35 @@
-{html_head}<link rel="stylesheet" type="text/css" href="{$ROOT_URL}plugins/{$PLUGIN_NAME}/include/charte.css">{/html_head}
-
+{html_head}
+<link rel="stylesheet" type="text/css" href="{$ROOT_URL}plugins/{$PLUGIN_NAME}/include/charte.css">
+{/html_head}
 <div id="content">
-<div class="titrePage">
-      <ul class="categoryActions">
+  <div class="titrePage">
+    <ul class="categoryActions">
       <li><a href="{$U_HOME}" title="{'return to homepage'|@translate}"><img src="{$ROOT_URL}{$themeconf.icon_dir}/home.png" class="button" alt="{'home'|@translate}"/></a></li>
     </ul>
-  <h2>Adult content config</h2>
+    <h2>Adult content config</h2>
+  </div>
+  <div id="autre_content">
+    <p>{$EXPLIC}</p>
+    <p>{$MAIN}</p>
+    <fieldset>
+      <form method="post" action="{$pwg_root}charte_user.php" >
+        <input type="hidden" name="groupe" value="+18"/>
+        <input class="submit" type="submit" name="login" value="{'ac_button_activ_18'|@translate}"/>
+        {'ac_text_activ_18'|@translate}
+      </form>
+    </fieldset>
+    <fieldset>
+      <form method="post" action="{$pwg_root}charte_user.php">
+        <input type="hidden" name="groupe" value="16-17"/>
+        <input class="submit" type="submit" name="login" value="{'ac_button_activ_16'|@translate}"/>
+        {'ac_text_activ_16'|@translate}
+      </form>
+    </fieldset>
+    <fieldset>
+      <form method="post" action="{$pwg_root}charte_user.php">
+        <input type="hidden" name="groupe" value="nothing"/>
+        <input class="submit" type="submit" name="Annuler" value="{'ac_retour_b'|@translate}"/>
+      </form>
+    </fieldset>
+  </div>
 </div>
-<div id="autre_content">
-<p>{$EXPLIC}</p>
-<p>{$MAIN}</p>
-<fieldset>
-<form method="post" action="{$pwg_root}charte_user.php" >
-    <input type="hidden" name="groupe" value="+18"/>
-    <input type="hidden" name="etat" value="{$ETAT}"/>
-    <input class="submit" type="submit" name="login" value="{'ac_button_activ_18'|@translate}"/>
-    {'ac_text_activ_18'|@translate}
-
-</form>
-</fieldset>
-<fieldset>
-<form method="post" action="{$pwg_root}charte_user.php">
-    <input type="hidden" name="groupe" value="16-17"/>
-    <input type="hidden" name="etat" value="{$ETAT}"/>
-    <input class="submit" type="submit" name="login" value="{'ac_button_activ_16'|@translate}"/>
-         {'ac_text_activ_16'|@translate}         
-</form>
-</fieldset>
-<fieldset>
-<form method="post" action="{$pwg_root}charte_user.php">
-    <input type="hidden" name="groupe" value="nothing"/>
-    <input type="hidden" name="etat" value="{$ETAT}"/>
-          <input class="submit" type="submit" name="Annuler" value="{'ac_retour_b'|@translate}"/>
-</form>
-</fieldset>
-</div>
-</div>
Index: /extensions/adult_content/template/OS_default/choose.tpl
===================================================================
--- /extensions/adult_content/template/OS_default/choose.tpl	(revision 9563)
+++ /extensions/adult_content/template/OS_default/choose.tpl	(revision 9564)
@@ -3,5 +3,5 @@
   <ul>
 	<li>
-	  <a href="{$pwg_root}plugins/{$AC_NAME}/charte_user.php?etat={$AC_ETAT}">{$AC_MSG}</a>
+	  <a href="{$pwg_root}plugins/{$AC_NAME}/charte_user.php">{$AC_MSG}</a>
 	</li>
   </ul>
Index: /extensions/adult_content/template/Pure_default/choose.tpl
===================================================================
--- /extensions/adult_content/template/Pure_default/choose.tpl	(revision 9563)
+++ /extensions/adult_content/template/Pure_default/choose.tpl	(revision 9564)
@@ -3,5 +3,5 @@
   <ul>
 	<li>
-	  <a href="{$pwg_root}plugins/{$AC_NAME}/charte_user.php?etat={$AC_ETAT}">{$AC_MSG}</a>
+	  <a href="{$pwg_root}plugins/{$AC_NAME}/charte_user.php">{$AC_MSG}</a>
 	</li>
   </ul>
Index: /extensions/adult_content/template/default/choose.tpl
===================================================================
--- /extensions/adult_content/template/default/choose.tpl	(revision 9563)
+++ /extensions/adult_content/template/default/choose.tpl	(revision 9564)
@@ -3,5 +3,5 @@
   <ul>
 	<li>
-	  <a href="{$pwg_root}plugins/{$AC_NAME}/charte_user.php?etat={$AC_ETAT}">{$AC_MSG}</a>
+	  <a href="{$pwg_root}plugins/{$AC_NAME}/charte_user.php">{$AC_MSG}</a>
 	</li>
   </ul>
Index: /extensions/adult_content/template/flop_mauve/choose.tpl
===================================================================
--- /extensions/adult_content/template/flop_mauve/choose.tpl	(revision 9563)
+++ /extensions/adult_content/template/flop_mauve/choose.tpl	(revision 9564)
@@ -3,5 +3,5 @@
   <ul>
 	<li>
-	  <a href="{$pwg_root}plugins/{$AC_NAME}/charte_user.php?etat={$AC_ETAT}">{$AC_MSG}</a>
+	  <a href="{$pwg_root}plugins/{$AC_NAME}/charte_user.php">{$AC_MSG}</a>
 	</li>
   </ul>
Index: /extensions/adult_content/template/gally-default/choose.tpl
===================================================================
--- /extensions/adult_content/template/gally-default/choose.tpl	(revision 9563)
+++ /extensions/adult_content/template/gally-default/choose.tpl	(revision 9564)
@@ -3,5 +3,5 @@
   <ul>
 	<li>
-	  <a href="{$pwg_root}plugins/{$AC_NAME}/charte_user.php?etat={$AC_ETAT}">{$AC_MSG}</a>
+	  <a href="{$pwg_root}plugins/{$AC_NAME}/charte_user.php">{$AC_MSG}</a>
 	</li>
   </ul>
