Skip to content
philcali edited this page Jan 26, 2012 · 2 revisions

Welcome to the ues_meta_viewer wiki!

The UES Meta Viewer allows users to query UES meta data from meta tables.

Adding New Entries

Should your plugin add data with meta information, you can add that information without having to patch this codebase.

Your plugin must handle the ues_meta_supported_types event, and directly add your support instance. The meta viewer only needs to know the names of the support type and its default fields to query against.

Note: The meta view will find the meta fields so do not include those.

class employee_support_meta implements supported_meta {
  public function name() {
    return get_string('employee', 'block_custom');
  }

  public function defaults() {
    return array('id', 'name', 'department');
  }
}

function event_handler($support) {
  $support->types[] = new employee_support_meta();
  return true;
}

Customizing Visibility

Even though users may share the ability to see meta viewer, a plugin may want to restrict or add new fields to query against. Plugins can achieve this by handling {type}_data_ui_keys, where type is the name of the supported meta data class.

// Filter the sport fields from non athletic employees
function ues_user_data_ui_keys($viewer) {
  if (!ues_employee::is_athletic_director($viewer->user)) {
    $not_sport = function ($key) { return !$key == 'user_sport'; };
    $viewer->keys = array_filter($viewer->keys, $not_sport);
  }

  return true;
}

Custom Searching / Output Formatting

Sometimes the data storing in the meta tables is not helpful for users. Plugins can format output by handling {type}_data_ui_element where type is the name of supported meta class.

The CPS has an example of this already.

The ui element is used for sql building too. You should refer to the meta_data_ui_element base class for more intimate details about what's available to the developer.

Recap

  • ues_meta_supported_types - to add supported types to query against
  • {type}_data_ui_keys - to customize visibility for certain fields
  • {type}_data_ui_element - add specific formatting or sql to the elements