NAME
CMS::Drupal::Modules::MembershipEntity::Term - Perl interface to a Drupal MembershipEntity membership term
VERSION
version 0.91
SYNOPSIS
use CMS::Drupal::Modules::MembershipEntity::Term;
$term = CMS::Drupal::Modules::MembershipEntity::Term->new(
'tid' => '4321',
'mid' => '1234',
'status' => '1',
'term' => 'One year',
'modifiers' => 'a:0:{}',
'start' => '1234567890',
'end' => '1234568999',
'array_position' => '2',
);
METHODS
is_active
Returns 1 if the Term has a status of 'active.' Note this does not mean it is the current Term (see below). Returns 0 for any other status.
is_current
Returns 1 if the Term is the current Term (i.e. the date-and-time now falls between the start date-and-time and the end date-and-time). (Note that the Term may be 'current' but not 'active', eg 'pending'.) Returns 0 otherwise.
is_future
Returns 1 if the Term has not yet begun (i.e. the start date-and-time is after the current time). Memberships can be renewed before they expire, so a Term can have a status of 'active' but be held in the future. Returns 0 otherwise.
was_renewal
Returns 1 if the Term was a renewal, as defined by the Term's array_position being greater than 1 (i.e., there was an earlier Term).
USAGE
Note: This module does not currently create or edit Membership Terms.
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 that retrieves all Membership Terms and creates an object for each of them (which is stored inside the parent Membership object). 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 Term actually has a start and an end date-and-time 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.
tid
The tid for the Term. Must be an integer.
mid
The mid for the parent Membership. Must be an integer.
status
The status of the Term. Must be an integer from 0 to 3.
modifiers
The special string containing any modifiers to the Term length.
start
The start date-and-time for the Term. Must be a Unix timestamp.
end
The end date-and-time for the Term. Must be a Unix timestamp.
array_position
The position the Term holds in the array of Terms belonging to the parent Membership. The array is sorted by start date-and-time ascending, and is indexed from 1, not from zero. (This parameter is passed automatically to this module if you use CMS::Drupal::Modules::MembershipEntity's fetch_memberships() method.)
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.