You are here

function og_menu_check_block_status in Organic Groups Menu (OG Menu) 5

2 calls to og_menu_check_block_status()
og_menu_activate_menus in ./og_menu.module
og_menu_overview in ./og_menu.module

File

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

Code

function og_menu_check_block_status() {
  $og_menus = _generate_menu_listing();
  foreach ($og_menus as $mid => $array) {
    $data = db_fetch_object(db_query('SELECT m.mid, b.module, b.delta, b.status, b.weight, b.region, b.visibility, b.pages FROM {menu} m INNER JOIN {blocks} b ON m.mid = b.delta WHERE b.module = "%s" AND mid = %d', 'menu', $mid));
    if ($data->status != 1) {
      db_query('UPDATE {blocks} SET status = %d WHERE delta = %d', 1, $mid);
    }
    if ($data->weight != $array['weight']) {
      db_query('UPDATE {blocks} SET weight = %d WHERE delta = %d', $array['weight'], $mid);
    }
    if ($data->visibility != 2) {
      db_query('UPDATE {blocks} SET visibility = %d WHERE delta = %d', 2, $mid);
    }
    if (!isset($data->pages) || strpos($data->pages, "<?php") === FALSE) {
      $gid = db_result(db_query('SELECT gid FROM {og_menu} WHERE mid = %d', $mid));
      $visibility = _check_block_status_generate_visibility($gid);
      db_query('UPDATE {blocks} SET pages = "%s" WHERE delta = %d', $visibility, $mid);
    }
  }
}