You are here

function _check_block_status_generate_visibility in Organic Groups Menu (OG Menu) 5

1 call to _check_block_status_generate_visibility()
og_menu_check_block_status in ./og_menu.module

File

./og_menu.module, line 386
Modifies the menu module to support menus specific to organic groups.

Code

function _check_block_status_generate_visibility($gid) {
  $visibility = "<?php\n\n  if (arg(0) == 'node' && is_numeric(arg(1))) {\n    \$nid = arg(1);\n  }\n  else {\n    \$path = request_uri();\n    \$path = drupal_get_normal_path(drupal_substr(\$path, 1));\n    \$nid = drupal_substr(\$path, 5);\n  }\n\n  if (!empty(\$nid) && arg(0) != 'admin' && arg(0) != 'user' && arg(1) != 'add'){\n    \$node = node_load(\$nid);\n  }\n\n  \$groups = \$node->og_groups;\n  if(empty(\$groups) && og_menu_is_group_type(\$node->type) === TRUE){\n    \$groups = (int) \$node->nid;\n  }\n\n  if (isset(\$groups)){\n    if (is_array(\$groups) && \$groups[0] == {$gid}){\n      return TRUE;\n    }\n    elseif(is_numeric(\$groups) && \$groups == {$gid}) {\n      return TRUE;\n    }\n    else {\n      return FALSE;\n    }\n  }\n  else {\n    return FALSE;\n  }\n\n?>";
  return $visibility;
}