You are here

function acquia_lift_debug_mode_enabled in Acquia Lift Connector 7.2

Determines if the Lift debugger should be enabled on the page request.

Return value

bool TRUE to include on the page, FALSE otherwise.

3 calls to acquia_lift_debug_mode_enabled()
acquia_lift_navbar in ./acquia_lift.module
Implements hook_navbar().
acquia_lift_page_build in ./acquia_lift.module
Implements hook_page_build().
acquia_lift_profiles_page_build in acquia_lift_profiles/acquia_lift_profiles.module
Implements hook_page_build().

File

./acquia_lift.module, line 3269
acquia_lift.module Provides Acquia Lift-specific personalization functionality.

Code

function acquia_lift_debug_mode_enabled() {
  $enabled = personalize_debug_mode_enabled();
  if (!$enabled) {
    return FALSE;
  }
  if (!acquia_lift_is_configured()) {
    return FALSE;
  }

  // Check to see if there is a session variable for debug mode.
  $in_session = isset($_SESSION[ACQUIA_LIFT_INSPECTOR_URL]);

  // Check to see if it was requested
  if ($in_session) {

    //turns on the personalizeDebugMode cookie
    setcookie('personalizeDebugMode', 1, time() + 60, '/');

    // Check to see if it should be turned off from URL parameter.
    if (isset($_GET[ACQUIA_LIFT_INSPECTOR_URL]) && $_GET[ACQUIA_LIFT_INSPECTOR_URL] == FALSE) {
      unset($_SESSION[ACQUIA_LIFT_INSPECTOR_URL]);

      //deletes the personalizeDebugMode cookie
      setcookie('personalizeDebugMode', "", time() - 3600);
      return FALSE;
    }
    return TRUE;
  }
  else {

    // Check to see if it was requested via URL parameter.
    if (!empty($_GET[ACQUIA_LIFT_INSPECTOR_URL])) {
      $_SESSION[ACQUIA_LIFT_INSPECTOR_URL] = TRUE;
      return TRUE;
    }
  }
  return FALSE;
}