You are here

function calendar_plugin_row::calendar_group_stripe in Calendar 7.3

Create a stripe based on group.

1 call to calendar_plugin_row::calendar_group_stripe()
calendar_plugin_row::render in includes/calendar_plugin_row.inc
Render a row object. This usually passes through to a theme template of some form, but not always.

File

includes/calendar_plugin_row.inc, line 663
Contains the Calendar row style plugin.

Class

calendar_plugin_row
Plugin which creates a view on the resulting object and formats it as a Calendar node.

Code

function calendar_group_stripe(&$result) {
  $colors = isset($this->options['colors']['calendar_colors_group']) ? $this->options['colors']['calendar_colors_group'] : array();
  if (empty($colors)) {
    return;
  }
  if (!function_exists('og_get_entity_groups')) {
    return;
  }
  $entity = $result->entity;
  $groups_for_entity = og_get_entity_groups($this->view->base_table, $entity);

  // The 7.1 version of OG.
  if (function_exists('og_label')) {
    if (count($groups_for_entity)) {
      foreach ($groups_for_entity as $gid => $group_name) {
        if (!array_key_exists($gid, $colors) || $colors[$gid] == CALENDAR_EMPTY_STRIPE) {
          continue;
        }
        $result->stripe[] = $colors[$gid];
        $result->stripe_label[] = $group_name;
      }
    }
  }
  else {
    if (count($groups_for_entity)) {
      foreach ($groups_for_entity as $entity_type => $gids) {
        foreach ($gids as $gid => $group_name) {
          if (!array_key_exists($gid, $colors) || $colors[$gid] == CALENDAR_EMPTY_STRIPE) {
            continue;
          }
          $result->stripe[] = $colors[$gid];
          $result->stripe_label[] = $group_name;
        }
      }
    }
  }
  return;
}