You are here

function skinr_ui_skin_status_set in Skinr 7.2

Menu callback; Updates the skin configuration's status.

1 string reference to 'skinr_ui_skin_status_set'
skinr_ui_menu in ./skinr_ui.module
Implements hook_menu().

File

./skinr_ui.admin.inc, line 11
Admin page callbacks for the Skinr UI module.

Code

function skinr_ui_skin_status_set($skin, $status) {

  // We require a token in the query string to prevent CSFR attacks.
  if (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], 'admin/structure/skinr/skin/' . $skin->sid . '/' . ($status ? 'enable' : 'disable'))) {
    return MENU_ACCESS_DENIED;
  }

  // Load an uncached version of the skin configuration object.
  $skin = skinr_skin_load_unchanged($skin->sid);

  // Let's save some time in skinr_skin_save() by setting $skin->original here.
  $skin->original = clone $skin;

  // Update the status and save the skin configuration.
  $skin->status = $status ? 1 : 0;
  skinr_skin_save($skin);

  // The skinr_context module, for instance, prevents enabling a skin in some
  // cases. So check for it.
  if ($skin->status == $status) {
    if ($status) {
      drupal_set_message(t('Skin configuration has been enabled.'));
    }
    else {
      drupal_set_message(t('Skin configuration has been disabled.'));
    }
  }
  else {
    drupal_set_message(t('Changing skin configuration status failed.'), 'warning');
  }

  // Return to the skin configuration overview page.
  drupal_goto('admin/structure/skinr');
}