Project

General

Profile

Revision a4f964ee

IDa4f964ee6d8de1faf4dab22ecd364386bbde4490
Parent ccec98d8
Child 1be93be6

Added by Andreas Kohlbecker over 6 years ago

helper function to determine the visibility of the cdm_ws_debug block

View differences:

7.x/modules/cdm_dataportal/cdm_api/cdm_api.module
1533 1533
    // The object has been found in the L1 cache.
1534 1534
    //
1535 1535
    $obj = $cacheL1_obj;
1536
    if (variable_get('cdm_webservice_debug', 1) && user_access('administer')) {
1536
    if (cdm_debug_block_visible()) {
1537 1537
      cdm_ws_debug_add($uri, $method, $data, 0, 0, NULL, 'cacheL1');
1538 1538
    }
1539 1539
  }
......
1545 1545
    $obj = unserialize($cacheL2_entry->data);
1546 1546
    $duration_parse = microtime(TRUE) - $duration_parse_start;
1547 1547

  
1548
    if (variable_get('cdm_webservice_debug', 1) && user_access('administer')) {
1548
    if (cdm_debug_block_visible()) {
1549 1549
      cdm_ws_debug_add($uri, $method, $data, 0, $duration_parse, NULL, 'cacheL2');
1550 1550
    }
1551 1551
  }
......
1567 1567
    $obj = cdm_load_obj($response_body);
1568 1568

  
1569 1569
    $duration_parse = microtime(TRUE) - $duration_parse_start;
1570
    if (variable_get('cdm_webservice_debug', 1) && user_access('administer')) {
1570

  
1571
    if (cdm_debug_block_visible()) {
1571 1572
      if ($obj || $response_body == "[]") {
1572 1573
        $status = 'valid';
1573 1574
      }
......
1689 1690
}
1690 1691

  
1691 1692
/**
1693
 * helper function to dtermine if the cdm_debug_block should be displayed or not
1694
 * the visibility depends on whether
1695
 *  - the block is enabled
1696
 *  - the visibility restrictions in the block settings are satisfied
1697
 */
1698
function cdm_debug_block_visible() {
1699
  static $is_visible = null;
1700

  
1701
  if($is_visible === null){
1702
      $block = block_load('cdm_api', 'cdm_ws_debug');
1703
      $is_visible = $block->status == 1;
1704
      if($is_visible){
1705
        $blocks = array($block);
1706
        // Checks the page, user role, and user-specific visibilty settings.
1707
        block_block_list_alter($blocks);
1708
        $is_visible = count($blocks) > 0;
1709
      }
1710
  }
1711
  return $is_visible;
1712
}
1713

  
1714
/**
1692 1715
 * @todo Please document this function.
1693 1716
 * @see http://drupal.org/node/1354
1694 1717
 */

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)