You are here

function og_og_create_links in Organic groups 6.2

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

Implementation of hook_og_create_links().

See also

og_details_block()

File

./og.module, line 2784
Code for the Organic Groups module.

Code

function og_og_create_links($group) {
  global $user;
  $post_types = og_get_types('group_post');
  $types = node_get_types();
  foreach ($post_types as $post_type) {

    // We used to check for node_access(create) but then node admins would get a false positive and see node types that they could not create.
    // When this becomes a proper menu in D6, we get sorting for free
    $type_name = $types[$post_type]->name;
    $type_url_str = str_replace('_', '-', $post_type);
    if (module_invoke($types[$post_type]->module, 'access', 'create', $post_type, $user)) {
      $links["create_{$post_type}"] = l(t('Create !type', array(
        '!type' => $type_name,
      )), "node/add/{$type_url_str}", array(
        'attributes' => array(
          'title' => t('Add a new !type in this group.', array(
            '!type' => $type_name,
          )),
        ),
        'query' => "gids[]={$group->nid}",
      ));
    }
  }
  return isset($links) ? $links : array();
}