Index: /extensions/Comments_Access_Manager/admin.php
===================================================================
--- /extensions/Comments_Access_Manager/admin.php	(revision 21116)
+++ /extensions/Comments_Access_Manager/admin.php	(revision 21117)
@@ -34,15 +34,12 @@
 	if (isset($_POST['submit']) and isset($_POST['CM_No_Comment_Anonymous']) and isset($_POST['CM_GroupComm']) and isset($_POST['CM_GroupValid1']) and isset($_POST['CM_GroupValid2']))
   {
-
-		$newconf_CM = array(
-      $version,
-      $_POST['CM_No_Comment_Anonymous'],
-      $_POST['CM_GroupComm'],
-      (isset($_POST['CM_AllowComm_Group'])?$_POST['CM_AllowComm_Group']:''),
-      $_POST['CM_GroupValid1'],
-      (isset($_POST['CM_ValidComm_Group1'])?$_POST['CM_ValidComm_Group1']:''),
-      $_POST['CM_GroupValid2'],
-      (isset($_POST['CM_ValidComm_Group2'])?$_POST['CM_ValidComm_Group2']:''),
-      );
+    $newconf_CM['CMVersion'] = $version;
+    $newconf_CM['CM_No_Comment_Anonymous'] = (isset($_POST['CM_No_Comment_Anonymous']) ? $_POST['CM_No_Comment_Anonymous'] : 'false');
+    $newconf_CM['CM_GROUPCOMM'] = (isset($_POST['CM_GroupComm']) ? $_POST['CM_GroupComm'] : 'false');
+    $newconf_CM['CM_ALLOWCOMM_GROUP'] = (isset($_POST['CM_AllowComm_Group']) ? $_POST['CM_AllowComm_Group'] : '');
+    $newconf_CM['CM_GROUPVALID1'] = (isset($_POST['CM_GroupValid1']) ? $_POST['CM_GroupValid1'] : 'false');
+    $newconf_CM['CM_VALIDCOMM1_GROUP'] = (isset($_POST['CM_ValidComm_Group1']) ? $_POST['CM_ValidComm_Group1'] : '');
+    $newconf_CM['CM_GROUPVALID2'] = (isset($_POST['CM_GroupValid2']) ? $_POST['CM_GroupValid2'] : 'false');
+    $newconf_CM['CM_VALIDCOMM2_GROUP'] = (isset($_POST['CM_ValidComm_Group2']) ? $_POST['CM_ValidComm_Group2'] : '');
 
     $conf['CommentsManager'] = serialize($newconf_CM);
@@ -76,5 +73,5 @@
 
     //configuration value for users group allowed to post comments
-    if (isset($conf_CM[3]) and $conf_CM[3] == $row['id'])
+    if (isset($conf_CM['CM_ALLOWCOMM_GROUP']) and $conf_CM['CM_ALLOWCOMM_GROUP'] == $row['id'])
 		{
 	  	$AllowComm = $row['id'];
@@ -82,5 +79,5 @@
 
     //configuration value for users group allowed to post comments
-    if (isset($conf_CM[5]) and $conf_CM[5] == $row['id'])
+    if (isset($conf_CM['CM_VALIDCOMM1_GROUP']) and $conf_CM['CM_VALIDCOMM1_GROUP'] == $row['id'])
 		{
 	  	$ValidComm1 = $row['id'];
@@ -88,5 +85,5 @@
 
     //configuration value for users group allowed to post comments
-    if (isset($conf_CM[7]) and $conf_CM[7] == $row['id'])
+    if (isset($conf_CM['CM_VALIDCOMM2_GROUP']) and $conf_CM['CM_VALIDCOMM2_GROUP'] == $row['id'])
 		{
 	  	$ValidComm2 = $row['id'];
@@ -129,16 +126,16 @@
     'CM_CFA'                        => $conf['comments_forall'],
     'CM_VALIDATION'                 => $conf['comments_validation'],
-    'CM_VERSION'                    => $conf_CM[0],
-		'CM_NO_COMMENT_ANO_TRUE'        => $conf_CM[1]=='true' ?  'checked="checked"' : '' ,
-		'CM_NO_COMMENT_ANO_FALSE'       => $conf_CM[1]=='false' ?  'checked="checked"' : '' ,
-    'CM_GROUPCOMM_TRUE'             => $conf_CM[2]=='true' ?  'checked="checked"' : '' ,
-    'CM_GROUPCOMM_FALSE'            => $conf_CM[2]=='false' ?  'checked="checked"' : '' ,
-    'CM_ALLOWCOMM_GROUP'            => $conf_CM[3],
-    'CM_GROUPVALID1_TRUE'           => $conf_CM[4]=='true' ?  'checked="checked"' : '' ,
-    'CM_GROUPVALID1_FALSE'          => $conf_CM[4]=='false' ?  'checked="checked"' : '' ,
-    'CM_VALIDCOMM1_GROUP'           => $conf_CM[5],
-    'CM_GROUPVALID2_TRUE'           => $conf_CM[6]=='true' ?  'checked="checked"' : '' ,
-    'CM_GROUPVALID2_FALSE'          => $conf_CM[6]=='false' ?  'checked="checked"' : '' ,
-    'CM_VALIDCOMM2_GROUP'           => $conf_CM[7],
+    'CM_VERSION'                    => $conf_CM['CMVersion'],
+		'CM_NO_COMMENT_ANO_TRUE'        => $conf_CM['CM_No_Comment_Anonymous']=='true' ?  'checked="checked"' : '' ,
+		'CM_NO_COMMENT_ANO_FALSE'       => $conf_CM['CM_No_Comment_Anonymous']=='false' ?  'checked="checked"' : '' ,
+    'CM_GROUPCOMM_TRUE'             => $conf_CM['CM_GROUPCOMM']=='true' ?  'checked="checked"' : '' ,
+    'CM_GROUPCOMM_FALSE'            => $conf_CM['CM_GROUPCOMM']=='false' ?  'checked="checked"' : '' ,
+    'CM_ALLOWCOMM_GROUP'            => $conf_CM['CM_ALLOWCOMM_GROUP'],
+    'CM_GROUPVALID1_TRUE'           => $conf_CM['CM_GROUPVALID1']=='true' ?  'checked="checked"' : '' ,
+    'CM_GROUPVALID1_FALSE'          => $conf_CM['CM_GROUPVALID1']=='false' ?  'checked="checked"' : '' ,
+    'CM_VALIDCOMM1_GROUP'           => $conf_CM['CM_VALIDCOMM1_GROUP'],
+    'CM_GROUPVALID2_TRUE'           => $conf_CM['CM_GROUPVALID2']=='true' ?  'checked="checked"' : '' ,
+    'CM_GROUPVALID2_FALSE'          => $conf_CM['CM_GROUPVALID2']=='false' ?  'checked="checked"' : '' ,
+    'CM_VALIDCOMM2_GROUP'           => $conf_CM['CM_VALIDCOMM2_GROUP'],
     )
   );
Index: /extensions/Comments_Access_Manager/changelog.txt
===================================================================
--- /extensions/Comments_Access_Manager/changelog.txt	(revision 21116)
+++ /extensions/Comments_Access_Manager/changelog.txt	(revision 21117)
@@ -85,2 +85,8 @@
               Correction and improvement of the Translation Repository en_UK
               Add zh_CN, thanks to : dennisyan
+
+2013-03-03:
+      2.5.0 - Compliance with Piwigo 2.5
+              Code refactory : Change config variables to assoc array and $_POST vars control before writing conf in database - Thx to flop25 for his advices ;-)
+              Update zh_CN, thanks to : winson and dennisyan
+              Add pt_BR, thanks to : flaviove
Index: /extensions/Comments_Access_Manager/include/functions.inc.php
===================================================================
--- /extensions/Comments_Access_Manager/include/functions.inc.php	(revision 21116)
+++ /extensions/Comments_Access_Manager/include/functions.inc.php	(revision 21117)
@@ -46,5 +46,5 @@
   {
     // Does not allow empty author name on comments for all
-    if ((isset($conf_CM[1]) and $conf_CM[1] == 'true') and $comm['author'] == 'guest')
+    if ((isset($conf_CM['CM_No_Comment_Anonymous']) and $conf_CM['CM_No_Comment_Anonymous'] == 'true') and $comm['author'] == 'guest')
     {
       $comment_action = 'reject';
@@ -52,5 +52,5 @@
     }
     
-    if ((isset($conf_CM[6]) and $conf_CM[6] == 'true') and !is_a_guest() and $conf['comments_validation'])
+    if ((isset($conf_CM['CM_GROUPVALID2']) and $conf_CM['CM_GROUPVALID2'] == 'true') and !is_a_guest() and $conf['comments_validation'])
     {
       if (CM_CheckValidGroup($comm['author']) or is_admin())
@@ -68,10 +68,10 @@
   if (!$conf['comments_forall'] and !is_admin())
   {
-    if ((isset($conf_CM[2]) and $conf_CM[2] == 'true') and (isset($conf_CM[4]) and $conf_CM[4] == 'false') and !CM_CheckAuthor($comm['author'])) // Comments authorized group set - Auto validation group unset 
+    if ((isset($conf_CM['CM_GROUPCOMM']) and $conf_CM['CM_GROUPCOMM'] == 'true') and (isset($conf_CM['CM_GROUPVALID1']) and $conf_CM['CM_GROUPVALID1'] == 'false') and !CM_CheckAuthor($comm['author'])) // Comments authorized group set - Auto validation group unset 
     {
       $comment_action = 'reject'; // Comment rejected if author is not in the allowed group
       array_push($page['errors'], l10n('CM_Not_Allowed_Author'));
     }
-    elseif ((isset($conf_CM[2]) and $conf_CM[2] == 'false') and (isset($conf_CM[4]) and $conf_CM[4] == 'true') and $conf['comments_validation']) // Comments authorized group unset - Auto validation group set
+    elseif ((isset($conf_CM['CM_GROUPCOMM']) and $conf_CM['CM_GROUPCOMM'] == 'false') and (isset($conf_CM['CM_GROUPVALID1']) and $conf_CM['CM_GROUPVALID1'] == 'true') and $conf['comments_validation']) // Comments authorized group unset - Auto validation group set
     {
       if (CM_CheckValidGroup($comm['author']) and $conf['comments_validation'])
@@ -84,5 +84,5 @@
       }
     }
-    elseif ((isset($conf_CM[2]) and $conf_CM[2] == 'true') and (isset($conf_CM[4]) and $conf_CM[4] == 'true') and $conf['comments_validation']) // Comments authorized group set - Auto validation group set
+    elseif ((isset($conf_CM['CM_GROUPCOMM']) and $conf_CM['CM_GROUPCOMM'] == 'true') and (isset($conf_CM['CM_GROUPVALID1']) and $conf_CM['CM_GROUPVALID1'] == 'true') and $conf['comments_validation']) // Comments authorized group set - Auto validation group set
     {
       if (!CM_CheckAuthor($comm['author']))
@@ -119,5 +119,5 @@
   $conf_CM = unserialize($conf['CommentsManager']);
   
-  if (isset($conf_CM[3]) and $conf_CM[3] <> -1)
+  if (isset($conf_CM['CM_ALLOWCOMM_GROUP']) and $conf_CM['CM_ALLOWCOMM_GROUP'] <> -1)
   {
     $query = '
@@ -130,5 +130,5 @@
     ON u.id = ug.user_id
 WHERE u.username LIKE "'.$author.'"
-  AND ug.group_id = '.$conf_CM[3].'
+  AND ug.group_id = '.$conf_CM['CM_ALLOWCOMM_GROUP'].'
 ;';
 
@@ -163,14 +163,14 @@
   if ($conf['comments_forall'])
   {
-    if (isset($conf_CM[7]) and $conf_CM[7] <> -1)
-    {
-      $group_id = $conf_CM[7];
+    if (isset($conf_CM['CM_VALIDCOMM2_GROUP']) and $conf_CM['CM_VALIDCOMM2_GROUP'] <> -1)
+    {
+      $group_id = $conf_CM['CM_VALIDCOMM2_GROUP'];
     }
   }
   else
   {
-    if (isset($conf_CM[5]) and $conf_CM[5] <> -1)
-    {
-      $group_id = $conf_CM[5];
+    if (isset($conf_CM['CM_VALIDCOMM1_GROUP']) and $conf_CM['CM_VALIDCOMM1_GROUP'] <> -1)
+    {
+      $group_id = $conf_CM['CM_VALIDCOMM1_GROUP'];
     }
   }
Index: /extensions/Comments_Access_Manager/include/upgradedb.inc.php
===================================================================
--- /extensions/Comments_Access_Manager/include/upgradedb.inc.php	(revision 21116)
+++ /extensions/Comments_Access_Manager/include/upgradedb.inc.php	(revision 21117)
@@ -45,5 +45,5 @@
   $Newconf_CM = unserialize($conf_CM['value']);
   
-  $Newconf_CM[0] = $version;
+  $Newconf_CM[CMVersion] = $version;
   
   $update_conf = serialize($Newconf_CM);
@@ -128,3 +128,39 @@
   conf_update_param('CommentsManager', pwg_db_real_escape_string($update_conf));
 }
+
+
+/* upgrade from 2.4 to 2.5 */
+/* *********************** */
+function upgradeCM_240_250()
+{
+  global $conf;
+
+  // Upgrading options - Changing config variables to assoc array
+  // ------------------------------------------------------------
+  
+  // Upgrade $conf_CM options
+  $conf_CM = unserialize($conf['CommentsManager']);
+
+  $Newconf_CM = array(
+    'CMVersion'               => $conf_CM[0],
+    'CM_No_Comment_Anonymous' => $conf_CM[1],
+    'CM_GROUPCOMM'            => $conf_CM[2],
+    'CM_ALLOWCOMM_GROUP'      => $conf_CM[3],
+    'CM_GROUPVALID1'          => $conf_CM[4],
+    'CM_VALIDCOMM1_GROUP'     => $conf_CM[5],
+    'CM_GROUPVALID2'          => $conf_CM[6],
+    'CM_VALIDCOMM2_GROUP'     => $conf_CM[7]
+  );
+
+  // unset obsolete conf
+  // -------------------
+  for ($i = 0; $i <= 7; $i++)
+  {
+    unset ($conf_CM[$i]);
+  }
+
+  $update_conf = serialize($Newconf_CM);
+
+  conf_update_param('CommentsManager', pwg_db_real_escape_string($update_conf));
+}
 ?>
Index: /extensions/Comments_Access_Manager/maintain.inc.php
===================================================================
--- /extensions/Comments_Access_Manager/maintain.inc.php	(revision 21116)
+++ /extensions/Comments_Access_Manager/maintain.inc.php	(revision 21117)
@@ -16,5 +16,14 @@
   $version = $plugin['version'];
 	
-  $default = array($version,'false','false',-1,'false',-1,'false',-1);
+  $default = array(
+    'CMVersion'               => $version,
+    'CM_No_Comment_Anonymous' => 'false',
+    'CM_GROUPCOMM'            => 'false',
+    'CM_ALLOWCOMM_GROUP'      => -1,
+    'CM_GROUPVALID1'          => 'false',
+    'CM_VALIDCOMM1_GROUP'     => -1,
+    'CM_GROUPVALID2'          => 'false',
+    'CM_VALIDCOMM2_GROUP'     => -1
+    );
 
 	$query = '
@@ -62,4 +71,10 @@
       upgradeCM_221_222();
     }
+
+    // upgrade from 2.4 to 2.5
+    if (version_compare($conf_CM[0], '2.5.0') < 0)
+    {
+      upgradeCM_240_250();
+    }
   }
   
