Diff
Modified: branches/invitation_throttling/app/controllers/networks_controller.rb (2016 => 2017)
--- branches/invitation_throttling/app/controllers/networks_controller.rb 2008-11-28 19:07:01 UTC (rev 2016)
+++ branches/invitation_throttling/app/controllers/networks_controller.rb 2008-11-28 19:42:35 UTC (rev 2017)
@@ -173,7 +173,7 @@
end
unless overflow_addresses.empty?
- error_msg += "<br/><br/>You can only send invitations to #{INVITATION_EMAIL_LIMIT} unique, valid, non-blank email addresses.<br/>The following addresses were not processed because of maximum allowed amount was exceeded:<br/>" + overflow_addresses.join("<br/>")
+ error_msg += "<br/><br/>You can only send invitations to X unique, valid, non-blank email addresses.<br/>The following addresses were not processed because of maximum allowed amount was exceeded:<br/>" + overflow_addresses.join("<br/>")
end
error_msg += "</span>"
Modified: branches/invitation_throttling/app/models/activity_limit.rb (2016 => 2017)
--- branches/invitation_throttling/app/models/activity_limit.rb 2008-11-28 19:07:01 UTC (rev 2016)
+++ branches/invitation_throttling/app/models/activity_limit.rb 2008-11-28 19:42:35 UTC (rev 2017)
@@ -92,4 +92,12 @@
return [action_allowed, (limit.reset_after ? (limit.reset_after - time_now) : nil)]
end
+
+ # returns the remaining allowance for the limited feature; NIL if unlimited or limit doesn't exist
+ def self.remaining_allowance(contributor, limit_feature)
+ limit = ActivityLimit.find(:first, :conditions => ["contributor_type = ? AND contributor_id = ? AND limit_feature = ?", contributor.class.name, contributor.id, limit_feature])
+ return nil unless limit
+ return (limit.limit_max ? (limit.limit_max - limit.current_count) : nil)
+ end
+
end
Modified: branches/invitation_throttling/app/views/networks/invite.rhtml (2016 => 2017)
--- branches/invitation_throttling/app/views/networks/invite.rhtml 2008-11-28 19:07:01 UTC (rev 2016)
+++ branches/invitation_throttling/app/views/networks/invite.rhtml 2008-11-28 19:42:35 UTC (rev 2017)
@@ -53,7 +53,8 @@
<table>
<tr>
<td style="text-align: left;">
- <%= info_icon_with_tooltip("To include several email addresses, use commas or semicolons to separate them.<br/>Please note that just #{INVITATION_EMAIL_LIMIT} first unique, valid, non-blank addresses will be processed.") %>
+ <% remaining_allowance = ActivityLimit.remaining_allowance(current_user, "group_invite") -%>
+ <%= info_icon_with_tooltip("To include several email addresses, use commas or semicolons to separate them.<br/>#{remaining_allowance ? "Please note that your current allowance is to send invitations to #{remaining_allowance} unique, valid, non-blank address(es) in the list." : "Please note that limitations on the number of invitations to be sent may apply."}") %>
Email address(es) to send invitations to:<br/>
<% email_addresses_val = ((params[:invitations].nil? || params[:invitations][:address_list].nil?) ? "" : params[:invitations][:address_list]) %>
<%= text_field_tag "invitations[address_list]", email_addresses_val, :style => "width: 500px; margin-bottom: 0.8em;" -%><br/>
Modified: branches/invitation_throttling/app/views/users/_invite.rhtml (2016 => 2017)
--- branches/invitation_throttling/app/views/users/_invite.rhtml 2008-11-28 19:07:01 UTC (rev 2016)
+++ branches/invitation_throttling/app/views/users/_invite.rhtml 2008-11-28 19:42:35 UTC (rev 2017)
@@ -8,7 +8,8 @@
<p style="line-heght: 1.5; margin-left: 1.5em">
<%= hidden_field_tag :invitations_user_id, current.id -%>
- <%= info_icon_with_tooltip("To include several email addresses, use commas or semicolons to separate them.<br/>Please note that just #{INVITATION_EMAIL_LIMIT} first unique, valid, non-blank addresses will be processed.") %>
+ <% remaining_allowance = ActivityLimit.remaining_allowance(current_user, "user_invite") -%>
+ <%= info_icon_with_tooltip("To include several email addresses, use commas or semicolons to separate them.<br/>#{remaining_allowance ? "Please note that your current allowance is to send invitations to #{remaining_allowance} unique, valid, non-blank address(es) in the list." : "Please note that limitations on the number of invitations to be sent may apply."}") %>
Email addresses to send invitations to:<br/>
<% email_addresses_val = ((params[:invitations].nil? || params[:invitations][:addr_to].nil?) ? "" : params[:invitations][:addr_to]) %>
<%= text_field_tag "invitations[addr_to]", email_addresses_val, :style => "width: 500px; margin-bottom: 0.5em;" -%><br/>
Modified: branches/invitation_throttling/config/environment_private.rb.pre (2016 => 2017)
--- branches/invitation_throttling/config/environment_private.rb.pre 2008-11-28 19:07:01 UTC (rev 2016)
+++ branches/invitation_throttling/config/environment_private.rb.pre 2008-11-28 19:42:35 UTC (rev 2017)
@@ -66,10 +66,6 @@
# The number of seconds for the cache timeout
CACHE_TIMEOUT_SECS = 120
-# The maximum number of invitation emails to send out
-# (if set to '-1' - unlimited)
-INVITATION_EMAIL_LIMIT = 10
-
# The maximum file size allowed for workflows
WORKFLOW_UPLOAD_MAX_BYTES = 20971520