From 6a408552cb15817137f1bee64de07f69f1470194 Mon Sep 17 00:00:00 2001 From: Victor Kareh Date: Wed, 2 Mar 2011 16:57:40 -0500 Subject: [PATCH] Issue #843632: Add more time frames. --- node_limitnumber.module | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diff --git a/node_limitnumber.module b/node_limitnumber.module index e92f66f..1ff4ea4 100644 --- a/node_limitnumber.module +++ b/node_limitnumber.module @@ -97,6 +97,16 @@ function _node_limitnumber_check_limit($time, $node, $user, $limit) { $q = "SELECT nid FROM {node} WHERE type = '%s' AND uid = %d"; $result = db_query($q, $node->type, $user->uid); break; + case 'minutely': + $q = "SELECT nid FROM {node} WHERE type = '%s' AND uid = %d AND created > %d"; + $minute = strtotime(substr(date('c'), 0, 17) . '00'); + $result = db_query($q, $node->type, $user->uid, $minute); + break; + case 'hourly': + $q = "SELECT nid FROM {node} WHERE type = '%s' AND uid = %d AND created > %d"; + $hour = strtotime(substr(date('c'), 0, 14) . '00:00'); + $result = db_query($q, $node->type, $user->uid, $hour); + break; case 'daily': $q = "SELECT nid FROM {node} WHERE type = '%s' AND uid = %d AND created > %d"; $day = strtotime(date('Y-m-d')); @@ -172,6 +182,8 @@ function node_limitnumber_rules_condition_limit_form($settings, &$form) { '#description' => t('Create the limit of nodes per time frame'), '#options' => array( 'none' => t('No Time Limit'), + 'minutely' => t('Per minute'), + 'hourly' => t('Hourly'), 'daily' => t('Daily'), 'weekly' => t('Weekly (Last 7 Days)'), 'monthly' => t('Monthly'), @@ -219,6 +231,16 @@ function node_limitnumber_rules_comment_limit($comment, $user, $settings) { $q = "SELECT cid FROM {comments} WHERE uid = %d"; $result = db_query($q, $user->uid); break; + case 'minutely': + $q = "SELECT cid FROM {comments} WHERE uid = %d AND timestamp > %d"; + $minute = strtotime(substr(date('c'), 0, 17) . '00'); + $result = db_query($q, $user->uid, $minute); + break; + case 'hourly': + $q = "SELECT cid FROM {comments} WHERE uid = %d AND timestamp > %d"; + $hour = strtotime(substr(date('c'), 0, 14) . '00:00'); + $result = db_query($q, $user->uid, $hour); + break; case 'daily': $q = "SELECT cid FROM {comments} WHERE uid = %d AND timestamp > %d"; $day = strtotime(date('Y-m-d')); @@ -254,6 +276,8 @@ function node_limitnumber_rules_comment_limit_form($settings, &$form) { '#description' => t('Create the limit of comments per time frame'), '#options' => array( 'none' => t('No Time Limit'), + 'minutely' => t('Per minute'), + 'hourly' => t('Hourly'), 'daily' => t('Daily'), 'monthly' => t('Monthly'), ), -- 1.7.1