Closed (fixed)
Project:
Node Limit Number
Version:
6.x-2.0-alpha3
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
29 Jan 2009 at 00:14 UTC
Updated:
4 Apr 2010 at 08:30 UTC
For those who are interested in limiting also the number of comments, here is the changes you need to do:
In node_limitnumber.module, add at the end the following function:
function node_limitnumber_comment($a1, $op) {
global $user;
// Verify that the user is not editing a previously posted node
$url = preg_replace('/\//', '_', $_GET['q']);
$r = strpos($url, t('edit'));
$account = $user;
if (($op == "form" || $op == "validate") && !$r && $user->uid != 1){
$limit = _get_limits_for_user ($account, 'comment');
if (!empty($limit)) {
$count = db_result(db_query("SELECT COUNT(*) AS cnt FROM {comments} t WHERE t.timestamp >= ". (time()-3600). " AND t.uid = '$account->uid'"));
if ($count >= $limit) {
form_set_error('', t("Sorry, you have reached the maximum of !limit comments you can post per hour.", array ('!limit' => $limit)));
watchdog('quota_by_role', "Reached limit of comments per hour");
}
}
}
}
In node_limitnumber.inc
Add after lines 17 and 61 ($pubtypes = node_get_types('names');), the following line:
$pubtypes['comment'] = "Comment";
Comments
Comment #1
ekrispin commentedSee also http://drupal.org/node/260055#comment-1502964 for the support for limiting comments in addition to nodes and for a duration of time.
Comment #2
jdwfly commentedThis has been added into the 6.x-2.0-alpha2 version of this module.
Comment #3
EHA commentedI'm testing 6.x.-2.0-alpha2. In Rules, I don't see option to limit comments, just "set the limit for the node type".
Please help, more information on implementing this feature.
Comment #4
EHA commented^Update: I now see the limit comments function on the 6.x-2.x-dev release.
However, I would appreciate help in working out the Rules for this. Basically, I need to limit comments on a specific node type to 1 per user. Any direction would be appreciated.
Comment #6
gausarts commentedSorry to reopen, I tested the latest alpha, but when I go to rules I found a condition is not configurable
Is it implemented yet? Thanks
Comment #7
waddles commentedIt is implemented but your Event needs to relate to the Comment module to trigger it.