<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/views/conferences_adm/mail_attendees.html.erb</filename>
    </added>
    <added>
      <filename>app/views/notification/conf_attendees_mail.text.plain.erb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,27 +1,28 @@
 class Notification &lt; ActionMailer::Base
   class InvalidEmail &lt; Exception; end
   class MustSupplyBody &lt; Exception; end
+
+  # Welcome mail - Sent to everybody at account creation time
   def welcome(person)
     sys_name = SysConf.value_for('title_text')
     recipients person.name_and_email
     from SysConf.value_for('mail_from')
-    subject _('Welcome! You have successfully registered at %s') % 
-      sys_name
+    subject comas_title(_('Welcome! You have successfully registered at %s') % 
+                        sys_name)
     body :name =&gt; person.name, 
          :login =&gt; person.login,
          :sys_name =&gt; sys_name,
-         :login_url =&gt; url_for(:only_path =&gt; false,
-                               :controller =&gt; 'people',
-                               :action =&gt; 'login')
+         :login_url =&gt; login_url
   end
 
+  # Password recovery mail
   def request_passwd(person, ip)
     sess = RescueSession.create_for(person)
     sys_name = SysConf.value_for('title_text')
 
     recipients person.name_and_email
     from SysConf.value_for('mail_from')
-    subject _('New password request for %s') % sys_name
+    subject comas_title(_('New password request for %s') % sys_name)
     body :name =&gt; person.name,
          :login =&gt; person.login,
          :sys_name =&gt; sys_name,
@@ -32,11 +33,12 @@ class Notification &lt; ActionMailer::Base
                                :r_session =&gt; sess.link)
   end
 
+  # Mail to send when somebody adds a user as a coauthor
   def added_as_coauthor(new_author, proposal, author)
     recipients new_author.name_and_email
     cc author.name_and_email
     from SysConf.value_for('mail_from')
-    subject _(&quot;You have been added as a coauthor&quot;)
+    subject comas_title(_(&quot;You have been added as a coauthor&quot;))
     body :conference_name =&gt; proposal.conference.name,
          :orig_author_name =&gt; author.name, 
          :new_author_name =&gt; new_author.name,
@@ -45,49 +47,84 @@ class Notification &lt; ActionMailer::Base
                                   :controller =&gt; 'proposals',
                                   :action =&gt; 'show',
                                   :id =&gt; proposal),
-         :login_url =&gt; url_for(:only_path =&gt; false,
-                               :controller =&gt; 'people',
-                               :action =&gt; 'login')
+         :login_url =&gt; login_url
   end
 
+  # Inviting a friend to a conference
   def conference_invitation(sender, dest, conference, invitation_text)
-    dest =~ RFC822::EmailAddress or raise InvalidEmail
-    raise MustSupplyBody if invitation_text.nil? or invitation_text.empty?
+    checks_for_open_mails(dest.email, mail_body)
 
     recipients dest
     from SysConf.value_for('mail_from')
-    subject _('Invitation to %s, sent by %s') % [conference.name, sender.name]
+    subject comas_title(_('Invitation to %s, sent by %s') % 
+                        [conference.name, sender.name])
     body :conference =&gt; conference.name,
          :sender_name =&gt; sender.name,
          :sender_email =&gt; sender.email,
-         :conference_url =&gt; url_for(:only_path =&gt; false,
-                                    :controller =&gt; 'conferences',
-                                    :action =&gt; 'show',
-                                    :id =&gt; conference),
+         :conference_url =&gt; conf_url(conference),
          :invitation_text =&gt; invitation_text
   end
 
+  # Arbitrary administrator-generated mail
   def admin_mail(sender, dest, title, mail_body)
-    dest.email =~ RFC822::EmailAddress or raise InvalidEmail
-    raise MustSupplyBody if mail_body.nil? or mail_body.empty?
-
-    cms_title = SysConf.value_for('title_text')
+    checks_for_open_mails(dest.email, mail_body)
 
     recipients dest.name_and_email
-    from cms_mail_from
-    subject '[cms_title] title' % [cms_title, title]
-    body :comas_title =&gt; cms_title,
+    from comas_mail_from
+    subject comas_title(title)
+    body(:comas_title =&gt; SysConf.value_for('title_text'),
          :mail_title =&gt; title,
          :mail_body =&gt; mail_body,
          :admin_name =&gt; sender.name,
          :admin_mail =&gt; sender.email,
-         :login_url =&gt; url_for(:only_path =&gt; false,
-                                    :controller =&gt; 'people',
-                                    :action =&gt; 'login')
+         :login_url =&gt; login_url)
+  end
+
+  # Mail sent to registered conference membres (who opted in)
+  def conf_attendees_mail(sender, dest, conf, title, mail_body)
+    checks_for_open_mails(dest.email, mail_body)
+
+    recipients dest.name_and_email
+    from comas_mail_from
+    subject comas_title(title)
+    body(:conf_name =&gt; conf.name,
+         :conf_url =&gt; conf_url(conf),
+         :mail_title =&gt; title,
+         :mail_body =&gt; mail_body,
+         :admin_name =&gt; sender.name,
+         :admin_mail =&gt; sender.email)
   end
 
   private
-  def cms_mail_from
+  # Basic sanity checks for mails sent with user-supplied data: Email
+  # address looks sane? Does it have a nonempty body?
+  def checks_for_open_mails(dest, body)
+    raise InvalidEmail unless dest =~ RFC822::EmailAddress
+    raise MustSupplyBody if body.nil? or body.empty?
+  end
+
+  # Generate an URL for the system login
+  def login_url
+    url_for(:only_path =&gt; false,
+            :controller =&gt; 'people',
+            :action =&gt; 'login')
+  end
+
+  # Generate the URL for the specified conference's information page
+  def conf_url(conf)
+    url_for(:only_path =&gt; false,
+            :controller =&gt; 'conference',
+            :action =&gt; 'show',
+            :id =&gt; conf)
+  end
+
+  # This Comas' title (including an easily identifiable prefix)
+  def comas_title(title='')
+    '[%s] %s' % [SysConf.value_for('title_text'), title]
+  end
+
+  # Who should system-generated mails be sent as?
+  def comas_mail_from
     '%s &lt;%s&gt;' % [SysConf.value_for('title_text'), 
                  SysConf.value_for('mail_from')]
   end</diff>
      <filename>app/models/notification.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>067dc555f94d6a491686a4fac03f955f66ccb030</id>
    </parent>
    <parent>
      <id>5e0ac36934b1b093088a55d529154e0892c1797e</id>
    </parent>
  </parents>
  <author>
    <name>Gunnar Wolf</name>
    <email>gwolf@gwolf.org</email>
  </author>
  <url>http://github.com/gwolf/comas/commit/00be0da92edd49b8e05e637b5ac2fbfa35fe2808</url>
  <id>00be0da92edd49b8e05e637b5ac2fbfa35fe2808</id>
  <committed-date>2009-02-24T12:19:05-08:00</committed-date>
  <authored-date>2009-02-24T12:19:05-08:00</authored-date>
  <message>Merge branch 'people_adm_mailing'</message>
  <tree>4796be537ce928e9aca33b4272368bc84b4c067d</tree>
  <committer>
    <name>Gunnar Wolf</name>
    <email>gwolf@gwolf.org</email>
  </committer>
</commit>
