You are here

function ginvite_by_mail_list in Group 7

Generate the e-mail invitation list.

Parameters

Group $group: The group to generate the list for.

Return value

array The render array for this page.

1 string reference to 'ginvite_by_mail_list'
ginvite_menu in modules/ginvite/ginvite.router.inc
Implements hook_menu().

File

modules/ginvite/admin/ginvite.inc, line 16
Group member invite admin callback and pages.

Code

function ginvite_by_mail_list(Group $group) {
  $invites = ginvite_get_group_invites($group);
  $page['info'] = array(
    '#prefix' => '<p>',
    '#suffix' => '</p>',
  );
  if (empty($invites)) {
    $page['info']['#markup'] = t("There are no e-mail invitations that haven't been accepted yet.");
  }
  else {
    $page['info']['#markup'] = t("Below you will find a list of unclaimed e-mail invitations.<br />You may still edit or delete them as long as they remain unclaimed.");
    $rows = array();
    $group_roles = group_role_labels();
    foreach ($invites as $iid => $data) {

      // Build the invitation's roles list.
      $roles = array_intersect_key($group_roles, array_flip(unserialize($data->roles)));

      // Build the operation links.
      $destination = drupal_get_destination();
      $operations['edit'] = array(
        'title' => t('edit'),
        'href' => "group/{$group->gid}/invite/mail/{$iid}/edit",
        'query' => $destination,
      );
      $operations['delete'] = array(
        'title' => t('delete'),
        'href' => "group/{$group->gid}/invite/mail/{$iid}/delete",
        'query' => $destination,
      );

      // Populate a table row with all this data.
      $rows[] = array(
        $data->mail,
        array(
          'data' => array(
            '#theme' => 'item_list__group_roles',
            '#items' => $roles,
          ),
        ),
        l(format_username(user_load($data->invited_by)), "user/{$data->invited_by}"),
        format_date($data->invited_on),
        array(
          'data' => array(
            '#theme' => 'links__ginvite_mail_operation_links',
            '#links' => $operations,
            '#attributes' => array(
              'class' => array(
                'links',
                'inline',
              ),
            ),
          ),
        ),
      );
    }
    $page['invites'] = array(
      '#theme' => 'table',
      '#header' => array(
        t('E-mail'),
        t('Roles'),
        t('Invited by'),
        t('Invited on'),
        t('Operations'),
      ),
      '#rows' => $rows,
    );
  }
  return $page;
}