You are here

function rb_misc_views_list_restrictions in Rules Bonus Pack 7

Helper function that lists all available views with their displays.

I wish I found a way to call this function with an argument, directly from the declaration of the action.

@tables array An array containing any restrictions on which Views base tables should be accepted. If empty, all base tables will be returned.

Return value

array An array of all views and their displays on the form 'view|display', formatted to be used as an select list.

4 calls to rb_misc_views_list_restrictions()
rb_misc_views_list in ./rb_misc.rules.inc
Helper function that lists all available views with their displays.
rb_misc_views_list_comment in ./rb_misc.rules.inc
Helper function that lists all available comment views with their displays.
rb_misc_views_list_node in ./rb_misc.rules.inc
Helper function that lists all available node views with their displays.
rb_misc_views_list_user in ./rb_misc.rules.inc
Helper function that lists all available user views with their displays.

File

./rb_misc.rules.inc, line 464
Miscellaneous conditions and actions for Rules.

Code

function rb_misc_views_list_restrictions($tables = array()) {
  $selectable_displays = array();
  foreach (views_get_all_views() as $view_name => $view) {
    if (count($tables) == 0 || in_array($view->base_table, $tables)) {
      foreach ($view->display as $display_name => $display) {
        $selectable_displays[$view_name . '|' . $display_name] = check_plain($view->human_name) . '|' . check_plain($display->display_title);
      }
    }
  }
  return $selectable_displays;
}