You are here

function features_admin_lock in Features 7.2

Page callback to lock or unlock a component.

Paths:

  • 'admin/structure/features/%feature/lock' (official router path)
  • 'admin/structure/features/%feature/lock/nojs/' . $component
  • 'admin/structure/features/%feature/lock/ajax/' . $component.

Parameters

\stdClass $feature: Loaded feature object to be processed for component locking.

string $type: (optional) Path fragment, which may be 'nojs' or 'ajax'.

string|null $component: (optional) Path fragment, specifying the component to lock. If NULL, all components will be locked/unlocked.

Return value

array|void Render element to display on the page, with a confirm form to confirm locking or unlocking the component. In case of 'ajax', nothing is returned, and the component is locked or unlocked without further confirmation, if the url is signed with a token.

Throws

\Exception In theme() if called too early in the request.

1 string reference to 'features_admin_lock'
features_menu in ./features.module
Implements hook_menu().

File

./features.admin.inc, line 1631
Forms for Features admin screens.

Code

function features_admin_lock($feature, $type = 'ajax', $component = NULL) {
  if ($type == 'ajax' && !empty($_GET['token']) && drupal_valid_token($_GET['token'], 'features/' . $feature->name . '/' . ($component ? $component : '')) == $_GET['token']) {
    if (features_feature_is_locked($feature->name, $component, FALSE)) {
      features_feature_unlock($feature->name, $component);
    }
    else {
      features_feature_lock($feature->name, $component);
    }
    $commands = array();
    $new_link = theme('features_lock_link', array(
      'feature' => $feature->name,
      'component' => $component,
    ));
    $commands[] = ajax_command_replace('#features-lock-link-' . $feature->name . ($component ? '-' . $component : ''), $new_link);
    $page = array(
      '#type' => 'ajax',
      '#commands' => $commands,
    );
    ajax_deliver($page);
  }
  else {

    /* @see \features_feature_lock_confirm_form() */
    return drupal_get_form('features_feature_lock_confirm_form', $feature, $component);
  }
}