NAME
CMS::Drupal::Modules::MembershipEntity::Term
VERSION
version 0.092
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',
);
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.)
METHODS
- is_active
-
Returns true if the Term has a status of 'active.' Note this does not mean it is the current Term (see below). Returns undef for any other status.
- is_current
-
Returns true if the Term is the current Term (i.e. the current time falls between the start date-and-time and the end date-and-time). Returns undef otherwise.
- is_future
-
Returns true 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.
- was_renewal
-
Returns true 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).