Ignore:
Timestamp:
May 26, 2011, 10:41:39 PM (13 years ago)
Author:
Eric
Message:

-- Features refactory --
When "Comments for all" is disabled:

  • Users in a specified group can post comments without admin validation when admin validation is enabled.
  • Nickname is mandatory for guests comments

When "Comments for all" is enabled:

  • Users in a specified group can post comments without admin validation when admin validation is enabled.
  • Only a specified group can post comments

-- Admin panel refactory --
The admin panel displays option related with the state of "Comments for all" option.

New version 2.2.2 hard coded for publication

Location:
extensions/Comments_Access_Manager/include
Files:
2 edited

Legend:

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

    r11069 r11070  
    4444  $conf_CM = unserialize($conf['CommentsManager']);
    4545
    46 // Does not allow empty author name on comments for all
    47   if (isset($conf_CM[1]) and $conf_CM[1] == 'true' and $comm['author'] == 'guest' and $conf['comments_forall'])
    48   {
    49     $comment_action = 'reject';
    50 
    51     array_push($infos, l10n('CM_Empty Author'));
     46  if ($conf['comments_forall'])
     47  {
     48    // Does not allow empty author name on comments for all
     49    if ((isset($conf_CM[1]) and $conf_CM[1] == 'true') and $comm['author'] == 'guest')
     50    {
     51      $comment_action = 'reject';
     52
     53      array_push($infos, l10n('CM_Empty Author'));
     54    }
     55    elseif ((isset($conf_CM[6]) and $conf_CM[6] == 'true') and $comm['author'] != 'guest')
     56    {
     57      if (CM_CheckValidGroup($comm['author']) or is_admin())
     58      {
     59        $comment_action = 'validate'; // Comment is validated if author is not in the validated group
     60      }
     61      else
     62      {
     63        $comment_action = 'moderate'; // Comment needs moderation if author is not in the validated group
     64      }
     65    }
    5266  }
    5367
     
    148162  $conf_CM = unserialize($conf['CommentsManager']);
    149163 
    150   if (isset($conf_CM[5]) and $conf_CM[5] <> -1)
    151   {
    152     $query = '
     164  if ($conf['comments_forall'])
     165  {
     166    if (isset($conf_CM[7]) and $conf_CM[7] <> -1)
     167    {
     168      $group_id = $conf_CM[7];
     169    }
     170  }
     171  else
     172  {
     173    if (isset($conf_CM[5]) and $conf_CM[5] <> -1)
     174    {
     175      $group_id = $conf_CM[5];
     176    }
     177  }
     178
     179  $query = '
    153180SELECT u.id,
    154181       u.username,
     
    159186    ON u.id = ug.user_id
    160187WHERE u.username LIKE "'.$author.'"
    161   AND ug.group_id = '.$conf_CM[5].'
     188  AND ug.group_id = '.$group_id.'
    162189;';
    163190
    164     $count = pwg_db_num_rows(pwg_query($query));
    165 
    166     if (is_null($count) or $count == 0)
    167     {
    168       return false;
    169     }
    170     else
    171       return true;
    172   }
     191  $count = pwg_db_num_rows(pwg_query($query));
     192
     193  if (is_null($count) or $count == 0)
     194  {
     195    return false;
     196  }
     197  else
     198    return true;
    173199}
    174200
  • extensions/Comments_Access_Manager/include/upgradedb.inc.php

    r11069 r11070  
    101101  conf_update_param('CommentsManager', pwg_db_real_escape_string($update_conf));
    102102}
     103
     104
     105/* upgrade from 2.2.1 to 2.2.2 */
     106/* *************************** */
     107function upgradeCM_221_222()
     108{
     109  global $conf;
     110
     111  // Upgrading options
     112  $query = '
     113SELECT value
     114  FROM '.CONFIG_TABLE.'
     115WHERE param = "CommentsManager"
     116;';
     117
     118  $result = pwg_query($query);
     119  $conf_CM = pwg_db_fetch_assoc($result);
     120   
     121  $Newconf_CM = unserialize($conf_CM['value']);
     122 
     123  $Newconf_CM[6] = 'false';
     124  $Newconf_CM[7] = '-1';
     125 
     126  $update_conf = serialize($Newconf_CM);
     127
     128  conf_update_param('CommentsManager', pwg_db_real_escape_string($update_conf));
     129}
    103130?>
Note: See TracChangeset for help on using the changeset viewer.