You are here

function acquia_lift_agent_delete_access in Acquia Lift Connector 7.2

Access callback for agent deletion.

1 call to acquia_lift_agent_delete_access()
acquia_lift_agent_list in ./acquia_lift.admin.inc
Page callback for full campaign listings.
1 string reference to 'acquia_lift_agent_delete_access'
acquia_lift_menu in ./acquia_lift.module
Implements hook_menu().

File

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

Code

function acquia_lift_agent_delete_access($agent) {

  // Personalize module is more restricted in what it allows deletion of it,
  // so if we personalize module allows deletion, then so do we.
  if (personalize_delete_agent_access($agent)) {
    return TRUE;
  }
  $delete_allowed = FALSE;

  // We also allow outright deletion of agents that are legacy agents, regardless
  // of status, or nested tests that have been retired.
  $legacy_campaigns = variable_get('acquia_lift_legacy_agents', array());
  if (in_array($agent->machine_name, $legacy_campaigns)) {
    $delete_allowed = TRUE;
  }
  else {
    module_load_include('inc', 'acquia_lift', 'acquia_lift.admin');
    $retired_tests = acquia_lift_get_retired_tests();
    foreach ($retired_tests as $parent => $tests) {
      foreach ($tests as $test) {
        if ($agent->machine_name == $test->machine_name) {

          // This is a retired test and can be deleted.
          $delete_allowed = TRUE;
          break 2;
        }
      }
    }
  }
  return user_access('manage personalized content') && $delete_allowed;
}