You are here

function configuration_stop_tracking_form_validate in Configuration Management 7

1 string reference to 'configuration_stop_tracking_form_validate'
configuration_tracking_form in ./configuration.admin.inc
Menu Callback Form.

File

./configuration.admin.inc, line 680

Code

function configuration_stop_tracking_form_validate($form, &$form_state) {
  if ($form_state['values']['op'] == t('Stop Tracking')) {
    $configuration_export = $form_state['configuration_export'];
    $current_config = configuration_get_configuration();
    foreach ($configuration_export as $component => $config) {
      foreach (array_keys(array_filter($config)) as $identifier) {

        // User is trying to Stop Tracking a component that is a dependency of another component
        if (!empty($current_config[$component][$identifier]['parent'])) {
          $parent_id = $current_config[$component][$identifier]['parent'];

          // See if the parent is also being UnTracking.
          $parent_untracked_too = FALSE;
          $dependencies = unserialize($current_config[$component][$identifier]['dependencies']);
          if (!empty($dependencies)) {
            foreach (array_unique($dependencies) as $dependency) {
              if (!empty($configuration_export[$dependency][$parent_id])) {
                $parent_untracked_too = TRUE;
              }
            }
          }
          if (!$parent_untracked_too) {
            form_set_error('packages', t('You cannot stop tracking configurations of a component that is a dependency of another component.'));
          }
        }
      }
    }
  }
}