You are here

function group_group_membership_metadata in Group 7

Implements hook_group_membership_metadata().

File

./group.group.inc, line 261
Hook implementations for the Group module.

Code

function group_group_membership_metadata(GroupMembership $group_membership) {
  $metadata = array();

  // Create an EMW to have easy access to the data we need.
  $emw = entity_metadata_wrapper('group_membership', $group_membership);
  if (!empty($group_membership->joined_on)) {
    $metadata[] = array(
      'description' => t('Joined on'),
      'value' => format_date($emw->joined_on
        ->value()),
    );
  }
  if (!empty($group_membership->requested_on)) {
    $metadata[] = array(
      'description' => t('Requested membership on'),
      'value' => format_date($emw->requested_on
        ->value()),
    );
  }
  if (!empty($group_membership->approved_on)) {
    $metadata[] = array(
      'description' => t('Approved on'),
      'value' => format_date($emw->approved_on
        ->value()),
    );
    $metadata[] = array(
      'description' => t('Approved by'),
      'value' => l($emw->approved_by
        ->label(), 'user/' . $group_membership->approved_by),
    );
  }
  if (!empty($group_membership->blocked_on)) {
    $metadata[] = array(
      'description' => t('Blocked on'),
      'value' => format_date($emw->blocked_on
        ->value()),
    );
    $metadata[] = array(
      'description' => t('Blocked by'),
      'value' => l($emw->blocked_by
        ->label(), 'user/' . $group_membership->blocked_by),
    );
    $metadata[] = array(
      'description' => t('Status before being blocked'),
      'value' => $emw->blocked_status
        ->label(),
    );
  }
  return $metadata;
}