Changeset 11069


Ignore:
Timestamp:
May 26, 2011, 7:00:46 PM (13 years ago)
Author:
Eric
Message:

Add new feature : Users in a specified group can post comments without admin validation when "Comments for all" is enabled and admin validation is enabled.
New version 2.2.1 hard coded for publication

Location:
extensions/Comments_Access_Manager
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • extensions/Comments_Access_Manager/admin.php

    r11017 r11069  
    3333// *************************************************************************
    3434
    35         if (isset($_POST['submit']) and isset($_POST['CM_No_Comment_Anonymous']) and isset($_POST['CM_GroupComm']))
     35        if (isset($_POST['submit']) and isset($_POST['CM_No_Comment_Anonymous']) and isset($_POST['CM_GroupComm']) and isset($_POST['CM_GroupValid']))
    3636  {
    3737
     
    4141      $_POST['CM_GroupComm'],
    4242      (isset($_POST['CM_AllowComm_Group'])?$_POST['CM_AllowComm_Group']:''),
     43      $_POST['CM_GroupValid'],
     44      (isset($_POST['CM_ValidComm_Group'])?$_POST['CM_ValidComm_Group']:''),
    4345      );
    4446
     
    5658  $groups[-1] = '---------';
    5759  $AllowComm = -1;
     60  $ValidComm = -1;
    5861       
    5962  //Check groups list in database
     
    7578                $AllowComm = $row['id'];
    7679                }
     80
     81    //configuration value for users group allowed to post comments
     82    if (isset($conf_CM[5]) and $conf_CM[5] == $row['id'])
     83                {
     84                $ValidComm = $row['id'];
     85                }
    7786  }
    7887
     
    8392      'group_options'=> $groups,
    8493      'group_selected' => $AllowComm
     94                        )
     95        );
     96  //Template initialization for validated group for comments
     97  $template->assign(
     98    'ValidComm_Group',
     99                array(
     100      'group_options'=> $groups,
     101      'group_selected' => $ValidComm
    85102                        )
    86103        );
     
    100117    'CM_GROUPCOMM_FALSE'            => $conf_CM[2]=='false' ?  'checked="checked"' : '' ,
    101118    'CM_ALLOWCOMM_GROUP'            => $conf_CM[3],
     119    'CM_GROUPVALID_TRUE'            => $conf_CM[4]=='true' ?  'checked="checked"' : '' ,
     120    'CM_GROUPVALID_FALSE'           => $conf_CM[4]=='false' ?  'checked="checked"' : '' ,
     121    'CM_VALIDCOMM_GROUP'            => $conf_CM[5],
    102122    )
    103123  );
  • extensions/Comments_Access_Manager/changelog.txt

    r11021 r11069  
    22** Change log **
    33
    4 -- 2011-05-23 : 2.2.0 - Initial Release
     4-- 2011-05-23
     5      2.2.0 - Initial Release
     6
     7-- 2011-05-26
     8      2.2.1 - Add new feature : Users in a specified group can post comments without admin validation when "Comments for all" is enabled and admin validation is enabled.
  • extensions/Comments_Access_Manager/include/functions.inc.php

    r11017 r11069  
    5252  }
    5353
    54 
    55 // Do not allow comments if user is not in an allowed group
    56   if (isset($conf_CM[2]) and $conf_CM[2] == 'true' and !$conf['comments_forall'] and !is_admin())
    57   {
    58     if (!CM_CheckAuthor($comm['author']))
    59     {
    60       $comment_action = 'reject';
    61 
     54// Rules on comments NOT for all
     55  if (!$conf['comments_forall'] and !is_admin())
     56  {
     57    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
     58    {
     59      $comment_action = 'reject'; // Comment rejected if author is not in the allowed group
    6260      array_push($infos, l10n('CM_Not_Allowed_Author'));
     61    }
     62    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
     63    {
     64      if (CM_CheckValidGroup($comm['author']))
     65      {
     66        $comment_action = 'validate'; // Comment is validated if author is not in the validated group
     67      }
     68      else
     69      {
     70        $comment_action = 'moderate'; // Comment needs moderation if author is not in the validated group
     71      }
     72    }
     73    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
     74    {
     75      if (!CM_CheckAuthor($comm['author']))
     76      {
     77        $comment_action = 'reject'; // Comment rejected if author is not in the allowed group
     78        array_push($infos, l10n('CM_Not_Allowed_Author'));
     79      }
     80      elseif (CM_CheckValidGroup($comm['author']))
     81      {
     82        $comment_action = 'validate'; // Comment is validated if author is not in the validated group
     83      }
     84      else
     85        $comment_action = 'moderate'; // Comment needs moderation if author is not in the validated group
    6386    }
    6487  }
     
    110133
    111134/**
     135 * Checks if comment's author name is in the admin's pre-validated group
     136 * avoid admins to validate comments for the members of this group
     137 *
     138 * @author   : author's name
     139 *
     140 * @returns  : Boolean (true if user's comment doesn't need validation / false if user's comment is moderated)
     141 *
     142 */
     143function CM_CheckValidGroup($author)
     144{
     145  global $conf;
     146 
     147        // Get CM configuration
     148  $conf_CM = unserialize($conf['CommentsManager']);
     149 
     150  if (isset($conf_CM[5]) and $conf_CM[5] <> -1)
     151  {
     152    $query = '
     153SELECT u.id,
     154       u.username,
     155       ug.user_id,
     156       ug.group_id
     157FROM '.USERS_TABLE.' AS u
     158  INNER JOIN '.USER_GROUP_TABLE.' AS ug
     159    ON u.id = ug.user_id
     160WHERE u.username LIKE "'.$author.'"
     161  AND ug.group_id = '.$conf_CM[5].'
     162;';
     163
     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  }
     173}
     174
     175
     176/**
    112177 * Get the plugin version and name
    113178 *
  • extensions/Comments_Access_Manager/include/upgradedb.inc.php

    r11017 r11069  
    7474  }
    7575}
     76
     77
     78/* upgrade from 2.2.0 to 2.2.1 */
     79/* *************************** */
     80function upgradeCM_220_221()
     81{
     82  global $conf;
     83
     84  // Upgrading options
     85  $query = '
     86SELECT value
     87  FROM '.CONFIG_TABLE.'
     88WHERE param = "CommentsManager"
     89;';
     90
     91  $result = pwg_query($query);
     92  $conf_CM = pwg_db_fetch_assoc($result);
     93   
     94  $Newconf_CM = unserialize($conf_CM['value']);
     95 
     96  $Newconf_CM[4] = 'false';
     97  $Newconf_CM[5] = '-1';
     98 
     99  $update_conf = serialize($Newconf_CM);
     100
     101  conf_update_param('CommentsManager', pwg_db_real_escape_string($update_conf));
     102}
    76103?>
  • extensions/Comments_Access_Manager/language/en_UK/help/plugin.lang.php

    r11017 r11069  
    66<br><br>
    77By default, when <b>&quot;comments for all&quot;</b> option is disabled, only registered users can post comments. With this option, you can restrict this behavior by specifying a user group. Thus, only registered users and members of this group may post comments.';
     8
     9// --------- Starting below: New or revised $lang ---- from version 2.2.1
     10$lang['CM_ValidCommTitle'] = 'Allow comments without validation by an administrator';
     11$lang['CM_ValidCommTitle_d'] = 'This option lets you specify a group of users whose comments will be provided without validation by the administrator when the gallery is configured to not allow comments to all and that the validation of comments by an administrator is required.
     12<br><br>
     13By default, when <b>&quot;comments all&quot;</b> are off and the validation of comments is enabled, the comments of all registered users are subject to validation by an administrator before being visible on the gallery. With this option, you can allow members of a group of your choice to post comments without such prior approval is required.';
     14// --------- End: New or revised $lang ---- from version 2.2.1
    815?>
  • extensions/Comments_Access_Manager/language/en_UK/plugin.lang.php

    r11022 r11069  
    1414Also available, the project\'s bugtracker: <a href="http://piwigo.org/bugs/" onclick="window.open(this.href);return false;">http://piwigo.org/bugs/</a>';
    1515$lang['CM_Empty Author'] = 'Comments author nickname is mandatory !';
     16
     17
     18// --------- Starting below: New or revised $lang ---- from version 2.2.1
     19$lang['CM_Validation_For_Group'] = 'Allow comments without validation by an administrator';
     20$lang['CM_ValidComm_Group'] = 'Select the group of users allowed to post comments without validation:';
     21$lang['CM_CommentsForAll'] = '"Comments for all" option <b style="color:red;">enabled</b>';
     22$lang['CM_CommentsForRegistered'] = '"Comments for all" option <b style="color:red;">disabled</b>';
     23// --------- End: New or revised $lang ---- from version 2.2.1
    1624?>
  • extensions/Comments_Access_Manager/language/fr_FR/help/plugin.lang.php

    r11017 r11069  
    11<?php
    2 $lang['CM_commentTitle'] = 'Commentaires : pseudo obligatoire pour les non-inscrits.';
    32$lang['CM_commentTitle_d'] = 'Lorsque les visiteurs non inscrits sont autorisés à poster des commentaires (<b>&quot;Commentaires pour tous&quot;</b> actif), cette option oblige le visiteur non inscrit à saisir un pseudo pour que le commentaire soit accepté.';
    43$lang['CM_GroupCommTitle'] = 'Autoriser les commentaires pour un groupe d\'utilisateurs';
     
    65<br><br>
    76Par défaut, lorsque les <b>&quot;commentaires pour tous&quot;</b> sont désactivés, seuls les utilisateurs inscrits peuvent poster des commentaires. Avec cette option, vous pouvez restreindre d\'avantage ce fonctionnement en précisant un groupe d\'utilisateurs. Ainsi, seuls les utilisateurs inscrits et faisant partie de ce groupe pourront poster des commentaires.';
     7
     8// --------- Starting below: New or revised $lang ---- from version 2.2.1
     9$lang['CM_commentTitle'] = 'Pseudo obligatoire pour les non-inscrits.';
     10$lang['CM_ValidCommTitle'] = 'Autoriser les commentaires sans validation par un administrateur';
     11$lang['CM_ValidCommTitle_d'] = 'Cette option permet de spécifier un groupe d\'utilisateurs dont les commentaires seront dispensés de validation par l\'administrateur lorsque la galerie est configurée pour ne pas autoriser les commentaires pour tous et que la validation des commentaires par un administrateur est requise.
     12<br><br>
     13Par défaut, lorsque les <b>&quot;commentaires pour tous&quot;</b> sont désactivés et que la validation des commentaires est activée, les commentaires de tous les utilisateurs inscrits sont soumis à validation par un administrateur avant d\'être visibles sur la galerie. Avec cette option, vous pouvez autoriser les membres d\'un groupe de votre choix à poster des commentaires sans que cette validation préalable ne soit nécessaire.';
     14// --------- End: New or revised $lang ---- from version 2.2.1
    815?>
  • extensions/Comments_Access_Manager/language/fr_FR/plugin.lang.php

    r11022 r11069  
    66$lang['CM_Disable'] = ' Désactiver (valeur par défaut)';
    77$lang['CM_Enable'] = ' Activer ';
    8 $lang['CM_No_Anonymous_Comments'] = 'Commentaires : Pseudo obligatoire pour les non-inscrits';
    98$lang['CM_Comments_For_Group'] = 'Autoriser les commentaires pour un groupe d\'utilisateurs';
    109$lang['CM_AllowedComm_Group'] = 'Sélectionnez le groupe d\'utilisateurs autorisé à poster des commentaires :';
     
    1514Egalement disponible, le bugtracker du projet: <a href="http://piwigo.org/bugs/" onclick="window.open(this.href);return false;">http://piwigo.org/bugs/</a>';
    1615$lang['CM_Empty Author'] = 'Le nom de l\'auteur du commentaire est obligatoire !';
     16
     17
     18// --------- Starting below: New or revised $lang ---- from version 2.2.1
     19$lang['CM_No_Anonymous_Comments'] = 'Pseudo obligatoire pour les non-inscrits';
     20$lang['CM_Validation_For_Group'] = 'Autoriser les commentaires sans validation par un administrateur';
     21$lang['CM_ValidComm_Group'] = 'Sélectionnez le groupe d\'utilisateurs autorisé à poster des commentaires sans validation :';
     22$lang['CM_CommentsForAll'] = 'Option "Commentaires pour tous" <b style="color:red;">activé</b>';
     23$lang['CM_CommentsForRegistered'] = 'Option "Commentaires pour tous" <b style="color:red;">désactivé</b>';
     24// --------- End: New or revised $lang ---- from version 2.2.1
    1725?>
  • extensions/Comments_Access_Manager/main.inc.php

    r11017 r11069  
    22/*
    33Plugin Name: Comments Access Manager
    4 Version: 2.2.0
     4Version: 2.2.1
    55Description: Gérer l'accès aux commentaites - Manage comments access
    66Plugin URI: http://piwigo.org/ext/extension_view.php?eid=
     
    1818include_once (CM_PATH.'include/functions.inc.php');
    1919
    20 load_language('plugin.lang', CM_PATH);
    21 $conf_CM = unserialize($conf['CommentsManager']);
    22 
    23 
    2420// Plugin administration panel
    2521add_event_handler('get_admin_plugin_menu_links', 'CM_admin_menu');
  • extensions/Comments_Access_Manager/maintain.inc.php

    r11017 r11069  
    1616  $version = $plugin['version'];
    1717       
    18   $default = array($version,'false','false',-1);
     18  $default = array($version,'false','false',-1,'false',-1);
    1919
    2020        $query = '
     
    4646  include_once (CM_PATH.'include/upgradedb.inc.php');
    4747
     48  // Database upgrade process
     49  if (isset($conf['CommentsManager']))
     50  {
     51    $conf_CM = unserialize($conf['CommentsManager']);
     52   
     53    // upgrade from 2.2.0 to 2.2.1
     54    if (version_compare($conf_CM[0], '2.2.1') < 0)
     55    {
     56      upgradeCM_220_221();
     57    }
     58  }
     59 
    4860  // Update plugin version number in #_config table and check consistency of #_plugins table
    4961  CM_version_update();
    5062
    51   load_conf_from_db('param like \'UserAdvManager\\_%\'');
     63  load_conf_from_db('param like \'CommentsManager\'');
    5264}
    5365
  • extensions/Comments_Access_Manager/template/admin.tpl

    r11017 r11069  
    99  jQuery('.cluetip').cluetip(
    1010  {ldelim}
    11     width: 550,
     11    width: 500,
    1212    splitTitle: '|'
    1313  {rdelim});
     
    2626
    2727  <fieldset>
     28    <fieldset>
     29    <div class="FieldTitle">
     30      {'CM_CommentsForAll'|@translate}
     31    </div>
     32    <br>
    2833    <ul>
    2934      <li>
     
    3944      <br><br>
    4045      </li>
    41 
     46    </ul>
     47    </fieldset>
     48   
     49    <fieldset>
     50    <div class="FieldTitle">
     51      {'CM_CommentsForRegistered'|@translate}
     52    </div>
     53    <br>
     54    <ul>
    4255      <li>
    4356        <label class="cluetip" title="{'CM_GroupCommTitle'|translate}|{'CM_GroupCommTitle_d'|translate}">
     
    6376      <br><br>
    6477      </li>
     78
     79      <li>
     80        <label class="cluetip" title="{'CM_ValidCommTitle'|translate}|{'CM_ValidCommTitle_d'|translate}">
     81          {'CM_Validation_For_Group'|@translate}
     82        </label>
     83      <br><br>
     84        <input type="radio" value="false" {$CM_GROUPVALID_FALSE} name="CM_GroupValid">
     85          {'CM_Disable'|@translate}
     86      <br>
     87        <input type="radio" value="true" {$CM_GROUPVALID_TRUE} name="CM_GroupValid">
     88          {'CM_Enable'|@translate}
     89      <br><br>
     90
     91      <ul>
     92        <li>
     93          <label>
     94            {'CM_ValidComm_Group'|@translate}
     95          </label>
     96        <br><br>
     97            {html_options name="CM_ValidComm_Group" options=$ValidComm_Group.group_options selected=$ValidComm_Group.group_selected}
     98        </li>
     99      </ul>
     100      <br><br>
     101      </li>
    65102    </ul>
     103    </fieldset>
    66104  </fieldset>
    67105
  • extensions/Comments_Access_Manager/template/cm.css

    r11017 r11069  
    44  font-weight:bold;
    55}
     6
     7/* CM instructions */
     8div.FieldTitle
     9{
     10  text-align:center;
     11  text-decoration: underline;
     12  font-weight:bolder;
     13}
Note: See TracChangeset for help on using the changeset viewer.