Loading

DADA::Profile

NAME

DADA::Profile

SYNOPSIS

DESCRIPTION

Public Methods

new

         my $p = DADA::Profile->new(
                { 
                        -email => 'user@example.com', 
                }
        ); 

new returns a DADA::Profile object.

new requires you to either pass the -email parameter, with a valid email address, or the, -from_session parameter, set to, 1:

 my $p = DADA::Profile->new(
        { 
                -from_session => 1, 
        }
 );

If invoked this way, the email address needed will be searched for within the saved session information for the particular environment.

If no email address is passed, or found within the session, this method will croak.

The email address passed needs not to have a valid profile, but some sort of email address needs to be passed.

exists

 my $prof = DADA::Profile->new({-email => 'user@example.com'}); 
 if($prof->exists){ 
        print "you exist!"; 
 }
 else { 
        print "you do not exist!"; 
 }

or even,

 if(DADA::Profile->new({-email => 'user@example.com'})->exists){ 
        print "it's alive!"; 
 }

exists let's you know if a profile with the email address, -email actually exists. Return 1 if it does, 0 if it doesn't.

subscribed_to_list

 $p->subscribed_to_list(
        {
                -list => 'my list',
        }
 ); 

subscribed_to_list returns 1 if the profile has a subscription to the list passed in, -list and will return 0 if they are not subscribed.

insert

(blinky blinky under construction!)

 $p->insert(
        {
                -password  => 'mypass',
                -activated => 1, 
                -auth_code => 1234, 
        }
 );

insert, inserts a profile. It's not specifically used to create new profiles and perhaps a shortcoming of this module (currently). What's strange is that if you attempt to insert two profiles dealing with the same address, you'll probably error out, just with the UNIQUE column of the table design... Gah.

Because of this somewhat sour design of this method, it's recommended you tread lightly and assume that the API will change, if not in the stable release, in a release sooner, rather than later. Outside of this module's code, it's used only once - making it somewhat of a private method, anyways. I'm going to forgo testing this method until I figure all that out... </notestomyself>

(see create())

subscribed_to

 my $subs = $p->subscribed_to; 

subscribed_to returns an array ref of all the lists the profile is subscribed to.

You can pass a -type param to change which sublists are looked at. The default is, list.

You can also pass the, -html_tmpl_params parameter (set to, "1") to return back a complex data structure that works well with HTML::Template:

If our profile was subscribed to the list, mylist this:

        my $p = DADA::Profile->new(
                {
                        -email => 'user@example.com'
                }
        ); 
        $p->subscribed_to(
                {
                        -list             => 'my list', 
                        -html_tmpl_params => 1, 
                }
        );

would return,

 [
  {
        'profile.email' => 'user@example.com',
    list            => 'mylist',
    subscribed      => 1
  }
 ]

is_activated

 if($p->is_activated){ 
        print "We are activated!"; 
 }
 else { 
        print "Nope. Not activated.";
 }

-activated returns either 1 if the profile is actived, or, 0, if the profile is not activated

You can activate a profile using the, activate() method:

 $p->activate; 

activate

 $p->activate; 

Or,

 $p->activate(
        {
                -activate => 1, 
        }
 ); 

Or, to deactivate:

 $p->activate(
        {
                -activate => 0, 
        }
 ); 

activate is used primarily to activate a profile. If no parameters are passed, the method will activate a profile.

You may pass the, -activate parameter, set to either 1 or, 0 to activate or deactivate the profile.

allowed_to_view_archives

  my $p = DADA::Profile->new({-email => 'user@example.com'}); 
 if($p->allowed_to_view_archives({-list => 'mylist'})){ 
        # Show 'em the archives!
 }
 else { 
        # No archives for you!
 }

allowed_to_view_archives returns either 1, if the profile is allowed to view archives for a particular list, or, 0 if they aren't.

The, -list parameter is required and needs to be filled out to a specific Dada Mail List (shortname). If no -list parameter is passed, this method will croak.

Several things will change the return value of this method:

If Profiles are not enabled (via the, $PROFILE_OPTIONS->{enabled} Config.pm variable), this method will always return, 1.

If Profiles are enabled, but the email address you're trying to look up profile information, doesn't actually have a profile, and profiles are enabled, this method will always return 0

Other than that, this method should return whatever is usually expected.

is_valid_password

 if($p->is_valid_password({-password => 'secret'})){ 
        print "let 'em in!"; 
 }
 else { 
        print "Show them the door!"; 
 } 

is_valid_password is used to check a passed password (passed in the, -password param), with the stored password. The stored password will be stored in an encrypted form, so don't try to match directly.

Will return 1 if the passwords do match and will return 0 if they do not match, or you forget to pass a password in the, -password param.

is_valid_registration

 my ($status, $errors) = $p->is_valid_registration(
                {
                        -email                         => 'user@example.com', 
                        -email_again               => 'user@example.com', 
                        -password                  => 'secret', 
                -recaptcha_challenge_field => '1234', 
                -recaptcha_response_field  => 'abcd', 
                }
 ); 

is_valid_registration is used to validate a new registration. This usually means taking information from an HTML form and passing it through this method, to make sure that the information passed is valid, so we can start the registration process. It requires a few parameters:

If CAPTCHA is enabled for Profiles, (via the Config.pm $PROFILE_OPTIONS->{gravatar_options}->{enable_gravators} parameter) the following two parameters also have to be passed:

-recaptcha_challenge_field and -recaptcha_response_field map to the 3rd and 4th arguments you have to pass in DADA::Security::AuthenCAPTCHA's method, check_answer, which is sadly currently under documented, but follows the same API as Captcha::reCAPTCHA:

http://search.cpan.org/~andya/Captcha-reCAPTCHA/lib/Captcha/reCAPTCHA.pm

(the check_answer method does, at the very least)

This method will return an array or two elements.

The first element, is the status. If it's set to, 1, then the information passed will work to create a brand new profile. If it's set to, 0, there's something wrong with the information.

The exact problems will be described in the second element passed, which will be a hashref. The key will describe the problem, and the value will be set to, 1 if a problem was found. Here's the keys that may be passed:

If $status returns 0, in no way should a new profile be registered.

update

 $p->update(
        {
                -password => 'my_new_password', 
        }
 ); 

update simply updates the information for the profile. In its current state, it looks like it should only be used to update the password of a profile, although any information about the profile, except the email address, can be updated.

Scarily, there's no checks on the validity of the information passed. This should be fixed in the future.

setup_profile

send_profile_activation_email

send_profile_reset_password_email

send_profile_reset_password_email

is_valid_activation

 $p->is_valid_activation(
        {
                -auth_code => $auth_code,
        }
 );

This method is similar to, is_valid_registration, as it returns a two-element array, the first element set to either 1, for validity and 0 for not, with the second element being a hashref of key/values describing what went wrong.

In this case, the only thing it's looking for the is the authorization code, which you should pass in the, -auth_code parameter.

This is the authorization code that used in the email sent out to confirm a new profile. If the authorization code is not current, $status will be set to, 0 and the second element hashref will have the current key/value pair:

        invalid_auth_code => 1

Other errors may join, invalid_auth_code in the future.

set_auth_code

        $p->set_auth_code; 

set_auth_code sets a new authorization code for the profile you're working on. It takes no arguments.

But, it will return the authorization code it creates.

This method will croak if the profile you're trying to set an authorization code doesn't actually exist.

AUTHOR

Justin Simoni http://dadamailproject.com

LICENSE AND COPYRIGHT

Copyright (c) 1999 - 2015 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.


Dada Mail Project

Download

Installation

Support