You are here

function pmpapi_groups_list in Public Media Platform API Integration 7

Form constructor for the PMPAPI groups list form.

1 string reference to 'pmpapi_groups_list'
pmpapi_groups_menu in pmpapi_groups/pmpapi_groups.module
Implements hook_menu().

File

pmpapi_groups/pmpapi_groups.admin.inc, line 14
Basic admin forms, validators, and submit handlers.

Code

function pmpapi_groups_list() {
  $group_list = pmpapi_fetch_groups();
  if ($group_list) {
    $edit_base = 'admin/config/services/pmp/groups/edit/';
    $delete_base = 'admin/config/services/pmp/groups/delete/';
    $vars['header'] = array(
      'title' => array(
        'data' => t('Group'),
      ),
      'guid' => array(
        'data' => t('Group GUID'),
      ),
      'edit' => array(
        'data' => t('Edit'),
      ),
      'delete' => array(
        'data' => t('Delete'),
      ),
    );
    $groups = array();
    $form = array();
    foreach ($group_list as $group) {
      $title = check_plain($group->attributes->title);
      $guid = $group->attributes->guid;
      $edit = l('Edit', $edit_base . $guid);
      $delete = l('Delete', $delete_base . $guid);
      $groups[] = array(
        $title,
        $guid,
        $edit,
        $delete,
      );
    }
    $vars['rows'] = $groups;
    return theme('table', $vars);
  }
  else {
    $form['pmpapi_groups_list_none'] = array(
      '#markup' => t('Unable to get a list of PMP groups.'),
    );
  }
  return $form;
}