You are here

function og_token_values in Organic groups 6

Same name and namespace in other branches
  1. 5.8 og.module \og_token_values()
  2. 5 og.module \og_token_values()
  3. 5.3 og.module \og_token_values()
  4. 5.7 og.module \og_token_values()
  5. 6.2 og.module \og_token_values()

Implementation of hook_token_values() for og specific tokens

File

./og.module, line 2662

Code

function og_token_values($type, $object = NULL) {
  $values = array();
  switch ($type) {
    case 'node':

      // Set some defaults.
      $values['ogname'] = '';
      $values['ogname-raw'] = '';
      $values['og-id'] = '';
      if (!empty($object->og_groups) && is_array($object->og_groups)) {
        $gids = array_filter($object->og_groups);
        foreach ($gids as $gid) {
          $title = db_result(db_query("SELECT title FROM {node} WHERE nid = %d", $gid));
          $values['ogname'] = check_plain($title);
          $values['ogname-raw'] = $title;
          $values['og-id'] = $gid;
          break;
        }
        return $values;
      }
      break;
  }
  return $values;
}