Changeset 21117


Ignore:
Timestamp:
Mar 3, 2013, 5:42:11 PM (7 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
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • extensions/Comments_Access_Manager/admin.php

    r20253 r21117  
    3434        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']))
    3535  {
    36 
    37                 $newconf_CM = array(
    38       $version,
    39       $_POST['CM_No_Comment_Anonymous'],
    40       $_POST['CM_GroupComm'],
    41       (isset($_POST['CM_AllowComm_Group'])?$_POST['CM_AllowComm_Group']:''),
    42       $_POST['CM_GroupValid1'],
    43       (isset($_POST['CM_ValidComm_Group1'])?$_POST['CM_ValidComm_Group1']:''),
    44       $_POST['CM_GroupValid2'],
    45       (isset($_POST['CM_ValidComm_Group2'])?$_POST['CM_ValidComm_Group2']:''),
    46       );
     36    $newconf_CM['CMVersion'] = $version;
     37    $newconf_CM['CM_No_Comment_Anonymous'] = (isset($_POST['CM_No_Comment_Anonymous']) ? $_POST['CM_No_Comment_Anonymous'] : 'false');
     38    $newconf_CM['CM_GROUPCOMM'] = (isset($_POST['CM_GroupComm']) ? $_POST['CM_GroupComm'] : 'false');
     39    $newconf_CM['CM_ALLOWCOMM_GROUP'] = (isset($_POST['CM_AllowComm_Group']) ? $_POST['CM_AllowComm_Group'] : '');
     40    $newconf_CM['CM_GROUPVALID1'] = (isset($_POST['CM_GroupValid1']) ? $_POST['CM_GroupValid1'] : 'false');
     41    $newconf_CM['CM_VALIDCOMM1_GROUP'] = (isset($_POST['CM_ValidComm_Group1']) ? $_POST['CM_ValidComm_Group1'] : '');
     42    $newconf_CM['CM_GROUPVALID2'] = (isset($_POST['CM_GroupValid2']) ? $_POST['CM_GroupValid2'] : 'false');
     43    $newconf_CM['CM_VALIDCOMM2_GROUP'] = (isset($_POST['CM_ValidComm_Group2']) ? $_POST['CM_ValidComm_Group2'] : '');
    4744
    4845    $conf['CommentsManager'] = serialize($newconf_CM);
     
    7673
    7774    //configuration value for users group allowed to post comments
    78     if (isset($conf_CM[3]) and $conf_CM[3] == $row['id'])
     75    if (isset($conf_CM['CM_ALLOWCOMM_GROUP']) and $conf_CM['CM_ALLOWCOMM_GROUP'] == $row['id'])
    7976                {
    8077                $AllowComm = $row['id'];
     
    8279
    8380    //configuration value for users group allowed to post comments
    84     if (isset($conf_CM[5]) and $conf_CM[5] == $row['id'])
     81    if (isset($conf_CM['CM_VALIDCOMM1_GROUP']) and $conf_CM['CM_VALIDCOMM1_GROUP'] == $row['id'])
    8582                {
    8683                $ValidComm1 = $row['id'];
     
    8885
    8986    //configuration value for users group allowed to post comments
    90     if (isset($conf_CM[7]) and $conf_CM[7] == $row['id'])
     87    if (isset($conf_CM['CM_VALIDCOMM2_GROUP']) and $conf_CM['CM_VALIDCOMM2_GROUP'] == $row['id'])
    9188                {
    9289                $ValidComm2 = $row['id'];
     
    129126    'CM_CFA'                        => $conf['comments_forall'],
    130127    'CM_VALIDATION'                 => $conf['comments_validation'],
    131     'CM_VERSION'                    => $conf_CM[0],
    132                 'CM_NO_COMMENT_ANO_TRUE'        => $conf_CM[1]=='true' ?  'checked="checked"' : '' ,
    133                 'CM_NO_COMMENT_ANO_FALSE'       => $conf_CM[1]=='false' ?  'checked="checked"' : '' ,
    134     'CM_GROUPCOMM_TRUE'             => $conf_CM[2]=='true' ?  'checked="checked"' : '' ,
    135     'CM_GROUPCOMM_FALSE'            => $conf_CM[2]=='false' ?  'checked="checked"' : '' ,
    136     'CM_ALLOWCOMM_GROUP'            => $conf_CM[3],
    137     'CM_GROUPVALID1_TRUE'           => $conf_CM[4]=='true' ?  'checked="checked"' : '' ,
    138     'CM_GROUPVALID1_FALSE'          => $conf_CM[4]=='false' ?  'checked="checked"' : '' ,
    139     'CM_VALIDCOMM1_GROUP'           => $conf_CM[5],
    140     'CM_GROUPVALID2_TRUE'           => $conf_CM[6]=='true' ?  'checked="checked"' : '' ,
    141     'CM_GROUPVALID2_FALSE'          => $conf_CM[6]=='false' ?  'checked="checked"' : '' ,
    142     'CM_VALIDCOMM2_GROUP'           => $conf_CM[7],
     128    'CM_VERSION'                    => $conf_CM['CMVersion'],
     129                'CM_NO_COMMENT_ANO_TRUE'        => $conf_CM['CM_No_Comment_Anonymous']=='true' ?  'checked="checked"' : '' ,
     130                'CM_NO_COMMENT_ANO_FALSE'       => $conf_CM['CM_No_Comment_Anonymous']=='false' ?  'checked="checked"' : '' ,
     131    'CM_GROUPCOMM_TRUE'             => $conf_CM['CM_GROUPCOMM']=='true' ?  'checked="checked"' : '' ,
     132    'CM_GROUPCOMM_FALSE'            => $conf_CM['CM_GROUPCOMM']=='false' ?  'checked="checked"' : '' ,
     133    'CM_ALLOWCOMM_GROUP'            => $conf_CM['CM_ALLOWCOMM_GROUP'],
     134    'CM_GROUPVALID1_TRUE'           => $conf_CM['CM_GROUPVALID1']=='true' ?  'checked="checked"' : '' ,
     135    'CM_GROUPVALID1_FALSE'          => $conf_CM['CM_GROUPVALID1']=='false' ?  'checked="checked"' : '' ,
     136    'CM_VALIDCOMM1_GROUP'           => $conf_CM['CM_VALIDCOMM1_GROUP'],
     137    'CM_GROUPVALID2_TRUE'           => $conf_CM['CM_GROUPVALID2']=='true' ?  'checked="checked"' : '' ,
     138    'CM_GROUPVALID2_FALSE'          => $conf_CM['CM_GROUPVALID2']=='false' ?  'checked="checked"' : '' ,
     139    'CM_VALIDCOMM2_GROUP'           => $conf_CM['CM_VALIDCOMM2_GROUP'],
    143140    )
    144141  );
  • extensions/Comments_Access_Manager/changelog.txt

    r20253 r21117  
    8585              Correction and improvement of the Translation Repository en_UK
    8686              Add zh_CN, thanks to : dennisyan
     87
     882013-03-03:
     89      2.5.0 - Compliance with Piwigo 2.5
     90              Code refactory : Change config variables to assoc array and $_POST vars control before writing conf in database - Thx to flop25 for his advices ;-)
     91              Update zh_CN, thanks to : winson and dennisyan
     92              Add pt_BR, thanks to : flaviove
  • 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?>
  • extensions/Comments_Access_Manager/maintain.inc.php

    r11208 r21117  
    1616  $version = $plugin['version'];
    1717       
    18   $default = array($version,'false','false',-1,'false',-1,'false',-1);
     18  $default = array(
     19    'CMVersion'               => $version,
     20    'CM_No_Comment_Anonymous' => 'false',
     21    'CM_GROUPCOMM'            => 'false',
     22    'CM_ALLOWCOMM_GROUP'      => -1,
     23    'CM_GROUPVALID1'          => 'false',
     24    'CM_VALIDCOMM1_GROUP'     => -1,
     25    'CM_GROUPVALID2'          => 'false',
     26    'CM_VALIDCOMM2_GROUP'     => -1
     27    );
    1928
    2029        $query = '
     
    6271      upgradeCM_221_222();
    6372    }
     73
     74    // upgrade from 2.4 to 2.5
     75    if (version_compare($conf_CM[0], '2.5.0') < 0)
     76    {
     77      upgradeCM_240_250();
     78    }
    6479  }
    6580 
Note: See TracChangeset for help on using the changeset viewer.