Ignore:
Timestamp:
Mar 3, 2013, 5:42:11 PM (11 years ago)
Author:
Eric
Message:

Next version is 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

Location:
extensions/Comments_Access_Manager/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/Comments_Access_Manager/include/functions.inc.php

    r14634 r21117  
    4646  {
    4747    // Does not allow empty author name on comments for all
    48     if ((isset($conf_CM[1]) and $conf_CM[1] == 'true') and $comm['author'] == 'guest')
     48    if ((isset($conf_CM['CM_No_Comment_Anonymous']) and $conf_CM['CM_No_Comment_Anonymous'] == 'true') and $comm['author'] == 'guest')
    4949    {
    5050      $comment_action = 'reject';
     
    5252    }
    5353   
    54     if ((isset($conf_CM[6]) and $conf_CM[6] == 'true') and !is_a_guest() and $conf['comments_validation'])
     54    if ((isset($conf_CM['CM_GROUPVALID2']) and $conf_CM['CM_GROUPVALID2'] == 'true') and !is_a_guest() and $conf['comments_validation'])
    5555    {
    5656      if (CM_CheckValidGroup($comm['author']) or is_admin())
     
    6868  if (!$conf['comments_forall'] and !is_admin())
    6969  {
    70     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
     70    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
    7171    {
    7272      $comment_action = 'reject'; // Comment rejected if author is not in the allowed group
    7373      array_push($page['errors'], l10n('CM_Not_Allowed_Author'));
    7474    }
    75     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
     75    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
    7676    {
    7777      if (CM_CheckValidGroup($comm['author']) and $conf['comments_validation'])
     
    8484      }
    8585    }
    86     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
     86    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
    8787    {
    8888      if (!CM_CheckAuthor($comm['author']))
     
    119119  $conf_CM = unserialize($conf['CommentsManager']);
    120120 
    121   if (isset($conf_CM[3]) and $conf_CM[3] <> -1)
     121  if (isset($conf_CM['CM_ALLOWCOMM_GROUP']) and $conf_CM['CM_ALLOWCOMM_GROUP'] <> -1)
    122122  {
    123123    $query = '
     
    130130    ON u.id = ug.user_id
    131131WHERE u.username LIKE "'.$author.'"
    132   AND ug.group_id = '.$conf_CM[3].'
     132  AND ug.group_id = '.$conf_CM['CM_ALLOWCOMM_GROUP'].'
    133133;';
    134134
     
    163163  if ($conf['comments_forall'])
    164164  {
    165     if (isset($conf_CM[7]) and $conf_CM[7] <> -1)
    166     {
    167       $group_id = $conf_CM[7];
     165    if (isset($conf_CM['CM_VALIDCOMM2_GROUP']) and $conf_CM['CM_VALIDCOMM2_GROUP'] <> -1)
     166    {
     167      $group_id = $conf_CM['CM_VALIDCOMM2_GROUP'];
    168168    }
    169169  }
    170170  else
    171171  {
    172     if (isset($conf_CM[5]) and $conf_CM[5] <> -1)
    173     {
    174       $group_id = $conf_CM[5];
     172    if (isset($conf_CM['CM_VALIDCOMM1_GROUP']) and $conf_CM['CM_VALIDCOMM1_GROUP'] <> -1)
     173    {
     174      $group_id = $conf_CM['CM_VALIDCOMM1_GROUP'];
    175175    }
    176176  }
  • extensions/Comments_Access_Manager/include/upgradedb.inc.php

    r11070 r21117  
    4545  $Newconf_CM = unserialize($conf_CM['value']);
    4646 
    47   $Newconf_CM[0] = $version;
     47  $Newconf_CM[CMVersion] = $version;
    4848 
    4949  $update_conf = serialize($Newconf_CM);
     
    128128  conf_update_param('CommentsManager', pwg_db_real_escape_string($update_conf));
    129129}
     130
     131
     132/* upgrade from 2.4 to 2.5 */
     133/* *********************** */
     134function upgradeCM_240_250()
     135{
     136  global $conf;
     137
     138  // Upgrading options - Changing config variables to assoc array
     139  // ------------------------------------------------------------
     140 
     141  // Upgrade $conf_CM options
     142  $conf_CM = unserialize($conf['CommentsManager']);
     143
     144  $Newconf_CM = array(
     145    'CMVersion'               => $conf_CM[0],
     146    'CM_No_Comment_Anonymous' => $conf_CM[1],
     147    'CM_GROUPCOMM'            => $conf_CM[2],
     148    'CM_ALLOWCOMM_GROUP'      => $conf_CM[3],
     149    'CM_GROUPVALID1'          => $conf_CM[4],
     150    'CM_VALIDCOMM1_GROUP'     => $conf_CM[5],
     151    'CM_GROUPVALID2'          => $conf_CM[6],
     152    'CM_VALIDCOMM2_GROUP'     => $conf_CM[7]
     153  );
     154
     155  // unset obsolete conf
     156  // -------------------
     157  for ($i = 0; $i <= 7; $i++)
     158  {
     159    unset ($conf_CM[$i]);
     160  }
     161
     162  $update_conf = serialize($Newconf_CM);
     163
     164  conf_update_param('CommentsManager', pwg_db_real_escape_string($update_conf));
     165}
    130166?>
Note: See TracChangeset for help on using the changeset viewer.