Module: MailManager
- Defined in:
- app/models/mail_manager/bounce.rb,
app/models/mail_manager.rb,
lib/mail_manager/engine.rb,
lib/mail_manager/version.rb,
app/models/mail_manager/mailer.rb,
app/models/mail_manager/contact.rb,
app/models/mail_manager/mailing.rb,
app/models/mail_manager/message.rb,
lib/workers/mail_manager/bounce_job.rb,
app/models/mail_manager/mailing_list.rb,
app/models/mail_manager/subscription.rb,
app/models/mail_manager/test_message.rb,
lib/workers/mail_manager/mailing_job.rb,
lib/workers/mail_manager/message_job.rb,
app/helpers/mail_manager/layout_helper.rb,
app/models/mail_manager/mailable_registry.rb,
lib/workers/mail_manager/test_message_job.rb,
app/helpers/mail_manager/application_helper.rb,
app/models/mail_manager/contactable_registry.rb,
app/helpers/mail_manager/subscriptions_helper.rb,
app/controllers/mail_manager/bounces_controller.rb,
app/controllers/mail_manager/contacts_controller.rb,
app/controllers/mail_manager/mailings_controller.rb,
app/controllers/mail_manager/messages_controller.rb,
app/controllers/mail_manager/application_controller.rb,
app/controllers/mail_manager/mailing_lists_controller.rb,
app/controllers/mail_manager/subscriptions_controller.rb
Overview
- Author
-
Chris Hauboldt ([email protected])
- Copyright
-
2009 Lone Star Internet Inc.
Worker used to check for ready Mailings and process/send them.
Defined Under Namespace
Modules: ApplicationHelper, LayoutHelper, SubscriptionsHelper Classes: ApplicationController, Bounce, BounceJob, BouncesController, Config, Contact, ContactableRegistry, ContactsController, Engine, Mailable, MailableRegistry, Mailer, Mailing, MailingJob, MailingList, MailingListsController, MailingsController, Message, MessageJob, MessagesController, Subscription, SubscriptionsController, TestMessage, TestMessageJob
Constant Summary collapse
- PLUGIN_ROOT =
used to easily know where the mail manager gem files are
File.(File.join(File.dirname(__FILE__),'..','..'))
- VERSION =
"3.2.25.1"
- Lock =
WithLock::Client
- LockException =
WithLock::LockException
Class Method Summary collapse
-
.abilities ⇒ Object
can be used to inject cancan abilities into your application.
-
.assets_path ⇒ Object
easily get a path to the gem’s assets.
-
.authorized?(user) ⇒ Boolean
logic for authorization mail manager.
-
.authorized_for_roles?(user, roles = []) ⇒ Boolean
checks if the given ‘user’ has a role.
-
.edit_route_for(contactable) ⇒ Object
gives the url for a contactable object (such as users or members or whatever you set up for mapping to your contacts.
-
.initialize_with_config(conf) ⇒ Object
sets up your MailManager.blah configuration options from config/mail_manager.yml and can override those with config/mail_manager.local.yml for development environments.
- .public_path?(path) ⇒ Boolean
Class Method Details
.abilities ⇒ Object
can be used to inject cancan abilities into your application
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/mail_manager/engine.rb', line 112 def self.abilities <<-EOT if MailManager.authorized?(user) can :manage, [ MailManager::Mailing, MailManager::MailingList, MailManager::Contact, MailManager::Subscription, MailManager::Bounce, MailManager::Message ] can [:send_test, :test, :schedule, :cancel], MailManager::Mailing can [:dismiss, :fail_address], MailManager::Bounce can [:delete, :undelete], MailManager::Contact end can [:subscribe, :double_opt_in, :thank_you], MailManager::Contact can [:unsubscribe, :unsubscribe_by_email_address], MailManager::Subscription EOT end |
.assets_path ⇒ Object
easily get a path to the gem’s assets
139 140 141 |
# File 'lib/mail_manager/engine.rb', line 139 def self.assets_path File.join(PLUGIN_ROOT,'assets') end |
.authorized?(user) ⇒ Boolean
logic for authorization mail manager
104 105 106 107 108 109 |
# File 'lib/mail_manager/engine.rb', line 104 def self.(user) return true unless ::MailManager.requires_authentication return false if user.blank? return true unless ::MailManager..present? (user, ::MailManager.) end |
.authorized_for_roles?(user, roles = []) ⇒ Boolean
checks if the given ‘user’ has a role
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/mail_manager/engine.rb', line 83 def self.(user,roles=[]) return true unless roles.present? user_roles = if ::MailManager.roles_method.present? if user.respond_to? ::MailManager.roles_method user.send(::MailManager.roles_method) else false end elsif user.respond_to?(:roles) user.roles elsif user.respond_to?(:role) [user.role] else [] end return false unless user_roles.present? user_roles = [user_roles] unless user_roles.is_a?(Array) roles.detect{|role| user_roles.map(&:to_sym).map(&:to_s).include?(role.to_s)}.present? end |
.edit_route_for(contactable) ⇒ Object
gives the url for a contactable object (such as users or members or whatever you set up for mapping to your contacts
134 135 136 |
# File 'lib/mail_manager/engine.rb', line 134 def self.edit_route_for(contactable) ContactableRegistry.edit_route_for(contactable.is_a?(String) ? contactable : contactable.class.name) end |
.initialize_with_config(conf) ⇒ Object
sets up your MailManager.blah configuration options from config/mail_manager.yml and can override those with config/mail_manager.local.yml for development environments
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/mail_manager/engine.rb', line 155 def self.initialize_with_config(conf) MailManager.secret ||= conf.secret rescue nil = ActionController::Base. default_site_url = "#{[:protocol]||'http'}://#{[:domain]}" MailManager.site_url ||= conf.site_url || default_site_url rescue default_site_url MailManager.dont_include_images_domains ||= conf.dont_include_images_domains || [] rescue [] MailManager. ||= conf. || 0.3 rescue 0.3 if conf.params.has_key?('table_prefix') MailManager.table_prefix ||= conf.table_prefix.to_s # allow empty else MailManager.table_prefix ||= 'mail_manager_' end MailManager.default_from_email_address ||= conf.default_from_email_address rescue nil MailManager.deliveries_per_run ||= (conf.deliveries_per_run || 50) rescue 50 MailManager.signup_email_address ||= conf.signup_email_address rescue nil MailManager.bounce ||= conf.bounce || {} rescue {} MailManager.unsubscribe_path ||= conf.unsubscribe_path || "/listmgr" rescue "/listmgr" MailManager.subscribe_path ||= conf.subscribe_path || "/listmgr/subscribe" rescue "/listmgr/subscribe" MailManager.double_opt_in_path ||= conf.double_opt_in_path || "/listmgr/confirm" rescue "/listmgr/confirm" MailManager.honey_pot_field ||= conf.honey_pot_field || "company_name" rescue "company_name" MailManager.subscribe_thank_you_path ||= conf.subscribe_thank_you_path || "/listmgr/subscribe_thank_you" rescue "/listmgr/subscribe_thank_you" MailManager.site_path ||= conf.site_path || "/" rescue "/" MailManager.layout ||= conf.layout || "mail_manager/application" rescue "mail_manager/application" MailManager.public_layout ||= conf.public_layout || "mail_manager/application" rescue "mail_manager/application" MailManager.use_show_for_resources ||= conf.use_show_for_resources || false rescue false MailManager.show_title ||= conf.show_title || true rescue true MailManager.requires_authentication ||= conf.requires_authentication || false rescue false MailManager. ||= conf. || [] rescue [] MailManager.roles_method ||= conf.roles_method || nil rescue nil MailManager.register_generic_mailable ||= conf.register_generic_mailable || false rescue false MailManager.exception_notification = {} MailManager.exception_notification[:to_addresses] ||= conf.exception_notification['to_addresses'] || [] rescue [] MailManager.exception_notification[:from_address] ||= conf.exception_notification['from_address'] || nil rescue nil end |
.public_path?(path) ⇒ Boolean
143 144 145 146 147 148 149 150 |
# File 'lib/mail_manager/engine.rb', line 143 def self.public_path?(path) [ MailManager.subscribe_path, MailManager.unsubscribe_path, MailManager.double_opt_in_path, MailManager.subscribe_thank_you_path ].detect{|public_path| public_path =~ /#{path}/i}.present? end |