You are here

function user_relationships_admin_types_list_page in User Relationships 7

Relationship Types List

1 string reference to 'user_relationships_admin_types_list_page'
user_relationships_menu in ./user_relationships.module
Implements hook_menu().

File

./user_relationships.admin.inc, line 443
User Relationships admin settings and config forms

Code

function user_relationships_admin_types_list_page() {
  $relationship_types = user_relationships_types_load();
  $headers = array(
    t('Name'),
    t('Type'),
    t('Requires Approval'),
    t('Operations'),
  );
  $rows = array();
  foreach ($relationship_types as $relationship) {
    $approval = t('No');
    if ($relationship->requires_approval) {
      if ($relationship->expires_val) {
        $approval = format_plural($relationship->expires_val, 'Yes (within 1 day)', 'Yes (within @count days)');
      }
      else {
        $approval = t('Yes');
      }
    }
    $rows[$relationship->rtid] = array(
      check_plain(user_relationships_type_get_name($relationship)),
      $relationship->is_oneway ? $relationship->is_reciprocal ? t('Reciprocal') : t('One-way') : t('Mutual'),
      $approval,
      l(t('edit'), "admin/config/people/relationships/{$relationship->rtid}/edit") . ' | ' . l(t('delete'), "admin/config/people/relationships/{$relationship->rtid}/delete"),
    );
  }
  $page['relationships'] = array(
    '#type' => 'fieldset',
    '#title' => t('Relationship Types'),
    '#weight' => 0,
  );
  $page['relationships']['list'] = array(
    '#theme' => 'table',
    '#header' => $headers,
    '#rows' => $rows,
    '#empty' => t('No relationships available.'),
  );
  drupal_alter('user_relationships_types_list', $page);
  return $page;
}