You are here

function spaces_admin_debug in Spaces 5

Provides a debug page to display all group privacy settings

1 string reference to 'spaces_admin_debug'
spaces_menu in ./spaces.module

File

./spaces.module, line 895

Code

function spaces_admin_debug() {
  drupal_add_css(drupal_get_path('module', 'spaces') . '/spaces.css');
  drupal_set_title('Debug spaces');

  // Query
  $result = db_query("\n    SELECT sf.*, n.title\n    FROM {spaces_features} sf\n    JOIN {node} n ON sf.gid = n.nid\n    WHERE n.status = 1\n    ORDER BY sf.gid ASC");
  $spaces = array();
  while ($row = db_fetch_object($result)) {
    $spaces[$row->gid][$row->id] = $row->value;
    if (!$spaces[$row->gid]['title']) {
      $spaces[$row->gid]['title'] = $row->title;
    }
  }

  // Generate list of features that have customizable options
  $features = array();
  foreach (spaces_features() as $id => $feature) {
    if (is_array($feature->spaces['options'])) {
      $features[] = $id;
    }
  }

  // Display table
  $rows = array();
  $headers = array_merge(array(
    t('Group ID'),
    t('Name'),
  ), $features);
  foreach ($spaces as $gid => $group) {
    $row = array(
      $gid,
      $group['title'],
    );
    foreach ($features as $feature) {
      $row[] = $group[$feature] ? array(
        'data' => $group[$feature],
        'class' => 'spaces-value',
      ) : array(
        'data' => '',
        'class' => 'space-value',
      );
    }
    $rows[] = $row;
  }
  return theme('table', $headers, $rows, array(
    'class' => 'spaces-debug',
  ));
}