Subscribe to receive updates on Dada Mail:

DADA::MailingList::Archives::Db



NAME

DADA::MailingList::Archives


SYNOPSIS

use DADA::MailingList::Archives;

        my $archive = DADA::MailingList::Archives->new(-List => \%list);


DESCRIPTION

Archive interface to a simple tied hash archiving system for messages saved in Dada Mail


SUBROUTINES

new

        my $archive = DADA::MailingList::Archives->new(-List => \%list);

this wil tie the db hash and get you going with this whole gosh darn thing if it has a valid list, it will open up the archive and get to work on it.


=cut

sub new {

        # the "new" function, wee
        my $that = shift; 
        my $class = ref($that) || $that; 
        
        my $self = SUPER::new $class (
                                                                  function => 'archives',
                                                                 );  
                                                                         
                                                                        
        #we gots some stuff passed to this darn thing
        my %args = (
        -List                => undef, 
        ignore_open_db_error => 0, 
        @_,
        );
         
         
        my $list_ref  = $args{-List}; 
        
        $self->{list_info} = $list_ref;
        $self->{name}      = $self->{list_info}->{list};        
        $self->{ignore_open_db_error} = $args{ignore_open_db_error};
        $self->init();
        
        return $self;

}

sub init { my $self = shift; $self->_open_db; }

sub can_display_attachments {


        my $self = shift; 
        return 0;

}

sub can_display_message_source {


        my $self = shift; 
        return 0;

}

sub print_message_source {

        my $self = shift; 
        
        croak "archive backend does not support viewing message source!" 
                unless can_display_message_source; 
}

sub get { my $self = shift; return $self->{DB_HASH}; }

sub save {
my $self = shift;
my $new_vals = shift;


        $self->_close_db;

        # hack. fix later. 
        my %tmp; 
        chmod($DADA::Config::FILE_CHMOD , $self->_db_filename)
                if -e $self->_db_filename; 
        tie %tmp, "AnyDBM_File", $self->_db_filename,  O_RDWR|O_CREAT, $DADA::Config::FILE_CHMOD   
        or croak 'couldn\'t tie '. $self->_db_filename . ' for reading: ' . $! .  '; If your server recently upgraded software or moved your lists to a different server, you may need to restore your list ' . $self->{function} . '. Visit ' . 
                        $DADA::Config::PROGRAM_URL . '?f=restore_lists '; 
        %tmp = %$new_vals; 
        untie %tmp; 
        $self->_open_db;
}

sub get_available_archives{
my $self = shift;


        my @all_dbs = ();
        my @available_lists = (); 
        my @available_archives = ();

        while (defined(my $present_list = <$DADA::Config::ARCHIVES /mj-*>)){

          $present_list =~ s#.*/##;
          $present_list =~ s/mj-//;
          $present_list =~ s/\..*//; 
          push(@all_dbs, $present_list);                                 
        }

         foreach my $all_those(@all_dbs) { 
                 if($all_those =~ m/.*-archive/) { 
                        push( @available_archives, $all_those)
                }
        }    
        @available_archives = sort(@available_archives); 
        my %seen = (); 
        my @unique = grep {! $seen{$_} ++ }  @available_archives; 
        return \@unique;

}

get_archive_entries

        my $entries = $archive -> get_archive_entries();

this will give you a refernce to an array that has the keys to your entries there.

get_archive_message

        my $message = get_archive_message($key);

gets the message of the given $key

get_archive_subject

        my $subject = get_archive_subject($key);

gets the subject of the given $key

get_archive_subject($key);

my $subject, $message, $format = $archive -> get_archive_subject($key);

gets the subject of the given $key

delete_archive

        delete_archive($key);

deletes the archive entry.

search_entries

 my $search_results = $archive->search_entries($keyword);

Given a $keyword, will return a array ref of archive key/ids that contain the keyword.

DESTROY

        DESTROY ALL ASTROMEN!\


COPYRIGHT

Copyright (c) 1999-2007 Justin Simoni All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.