You are here

function profile_views_get_fields in Views (for Drupal 7) 5

Same name and namespace in other branches
  1. 6.3 modules/profile.views.inc \profile_views_get_fields()
  2. 6.2 modules/profile.views.inc \profile_views_get_fields()
  3. 7.3 modules/profile.views.inc \profile_views_get_fields()

Get all profile fields

1 call to profile_views_get_fields()
profile_views_tables in modules/views_profile.inc
This include file implements views functionality on behalf of profile.module

File

modules/views_profile.inc, line 31

Code

function profile_views_get_fields() {
  $fields = array();
  $results = db_query("SELECT * FROM {profile_fields} ORDER BY category, weight");
  while ($row = db_fetch_object($results)) {

    // don't include private fields
    if (user_access('administer users') || $row->visibility != PROFILE_PRIVATE) {

      // make this work for default and modified profile.module

      //$row->options = unserialize($row->options);
      if (!empty($row->options)) {
        if (unserialize($row->options) == false) {

          // unserialized fields default version
          $options = $row->options;
          unset($row->options);
          $row->options['selection'] = $options;
        }
        else {

          // serialized fields or modified version
          $row->options = unserialize($row->options);
        }
      }
      $fields[] = $row;
    }
  }
  return $fields;
}