NAME
CMS::Drupal::Modules::MembershipEntity::Membership - Perl interface to a Drupal MembershipEntity membership
VERSION
version 0.91
SYNOPSIS
use CMS::Drupal::Modules::MembershipEntity::Membership;
$mem = CMS::Drupal::Modules::MembershipEntity::Membership->new(
'mid' => '1234',
'created' => '1234565432',
'changed' => '1234567890',
'uid' => '5678',
'status' => '1',
'member_id' => 'my_scheme_0123',
'type' => 'my_type',
'terms' => \%terms
);
METHODS
is_expired
Returns 1 if the Membership has status of 'expired'. Else returns 0.
is_active
Returns 1 if the Membership has status of 'active'. Else returns 0.
is_cancelled
Returns 1 if the Membership has status of 'cancelled'. Else returns 0.
is_pending
Returns 1 if the Membership has status of 'pending'. Else returns 0.
has_renewal
Returns 1 if the Membership has a renewal Term that has not yet started. This is defined by the value of $term->is_future and $term->is_active both being true for at least one of the Membership's Terms. Else returns 0.
print "User $mem->{'uid'} has already renewed" if $mem->has_renewal;
current_was_renewal
Returns 1 if the current Term belonging to the Membership was a renewal (i.e. not the Membership's first ever Term). Else returns 0.
USAGE
Note: This module does not currently create or edit Memberships.
This module is not designed to be called directly, although it can be. This module is called by CMS::Drupal::Modules::MembershipEntity, which has a method to retrieve Memberships and create an object for each of them. Error checking is handled in the latter module, so if you use this module directly you will have to do your own error checking, for example, to make sure that the Membership actually has at least one Term associated with it. (Yes, I know it should be impossible not to, but it happens. This is Drupal we are dealing with.)
PARAMETERS
All parameters are required. Consult the Drupal MembershipEntity documentation for more details.
mid
The mid for the Membership. Must be an integer.
created
The date-and-time the Membership was created. Must be a Unix timestamp.
changed
The date-and-time the Membership was last changed. Must be a Unix timestamp.
uid
The Drupal user ID for the owner of the Membership. Must be an integer.
status
The status of the Membership. Must be an integer from 0 to 3.
member_id
The unique Member ID that Drupal assigns to the Membership. This is separate from the uid and the mid and can be configured by the Drupal sysadmin to take almost any string-y format.
type
The Membership type.
terms
A hashref containing a CMS::Drupal::Modules::MembershipEntity::Term object for each term belonging to the Membership, keyed by the tid (term ID).
SEE ALSO
AUTHOR
Nick Tonkin <tonkin@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2015 by Nick Tonkin.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.