"Fossies" - the Fresh Open Source Software Archive

Member "email-reminder-0.8.1/EmailReminder/AnniversaryEvent.pm" (14 Mar 2015, 3313 Bytes) of package /linux/privat/email-reminder-0.8.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Perl source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "AnniversaryEvent.pm" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 0.7.7_vs_0.7.8.

    1 # This file is part of Email-Reminder.
    2 #
    3 # Email-Reminder is free software; you can redistribute it and/or
    4 # modify it under the terms of the GNU General Public License as
    5 # published by the Free Software Foundation; either version 3 of the
    6 # License, or (at your option) any later version.
    7 #
    8 # Email-Reminder is distributed in the hope that it will be useful,
    9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
   10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   11 # General Public License for more details.
   12 #
   13 # You should have received a copy of the GNU General Public License
   14 # along with Email-Reminder; if not, write to the Free Software
   15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
   16 # 02110-1301, USA.
   17 
   18 package EmailReminder::AnniversaryEvent;
   19 
   20 use strict;
   21 use warnings;
   22 use overload '""' => \&str;
   23 use EmailReminder::Utils;
   24 use EmailReminder::BirthdayEvent;
   25 
   26 use base qw(EmailReminder::BirthdayEvent);
   27 
   28 # XML tags
   29 __PACKAGE__->mk_accessors(qw(partner_name partner_email));
   30 
   31 sub str {
   32     my ($self) = @_;
   33     return $self->get_type . ':' . $self->get_id . ') ' . $self->get_name . ' and ' . $self->get_partner_name . ' - ' . $self->get_date;
   34 }
   35 
   36 # Hard-coded value for this event's type (class method)
   37 sub get_type
   38 {
   39     return 'anniversary';
   40 }
   41 
   42 # Number of fields this event adds to its parent (class method)
   43 sub get_nb_fields
   44 {
   45     my ($self) = @_;
   46     return $self->SUPER::get_nb_fields() + 2;
   47 }
   48 
   49 sub valid_partner_name {
   50     my ($class, $new_value) = @_;
   51     return $new_value;
   52 }
   53 
   54 sub valid_partner_email {
   55     my ($class, $new_value) = @_;
   56     return $new_value;
   57 }
   58 
   59 sub get_subject
   60 {
   61     my $self = shift;
   62 
   63     my $name         = $self->get_name();
   64     my $partner_name = $self->get_partner_name();
   65     my $occurence    = $self->get_occurence();
   66     my $th           = EmailReminder::Utils::get_th($occurence);
   67 
   68     if ($occurence) {
   69         return "${occurence}$th anniversary of $name and $partner_name";
   70     }
   71     else {
   72         return "Anniversary of $name and $partner_name";
   73     }
   74 }
   75 
   76 sub get_message_body
   77 {
   78     my $self = shift;
   79 
   80     # people involved
   81     my $name          = $self->get_name();
   82     my $email         = $self->get_email();
   83     my $partner_name  = $self->get_partner_name();
   84     my $partner_email = $self->get_partner_email();
   85     my $occurence     = $self->get_occurence();
   86     my $th            = EmailReminder::Utils::get_th($occurence);
   87     my $special_name  = EmailReminder::Utils::get_special_name($occurence) || '';
   88     my $when          = $self->{"WHEN"} || '';
   89 
   90     my $subject = $occurence ? "${occurence}$th anniversary of $name and $partner_name" : "Anniversary of $name and $partner_name";
   91     my $occurence_string = $occurence ? "${occurence}$th " : "";
   92 
   93     my $email_message = "";
   94     if ($email && $partner_email) {
   95         $email_message = "\n\nYou can reach them at $email and $partner_email respectively.";
   96     } elsif ($email) {
   97         $email_message = "\n\nYou can reach $name at $email.";
   98     } elsif ($partner_email) {
   99         $email_message = "\n\nYou can reach $partner_name at $partner_email.";
  100     }
  101 
  102     my $message = <<"MESSAGEEND";
  103 I just want to remind you that the ${occurence_string}anniversary ${special_name}of $name and $partner_name is $when.$email_message
  104 MESSAGEEND
  105 
  106     return $message;
  107 }
  108 
  109 1;