You are here

public function sweaver_plugin_styles::sweaver_style_enable in Sweaver 7

Same name and namespace in other branches
  1. 6 plugins/sweaver_plugin_styles/sweaver_plugin_styles.inc \sweaver_plugin_styles::sweaver_style_enable()

Menu callback, enable style.

File

plugins/sweaver_plugin_styles/sweaver_plugin_styles.inc, line 640
Styles plugin.

Class

sweaver_plugin_styles

Code

public function sweaver_style_enable() {
  $style_id = arg(6);

  // First we check if the style has a live version
  $check = db_select('sweaver_style', 's')
    ->fields('s', array(
    'style_id',
  ))
    ->condition('style_id', $style_id, '=')
    ->execute()
    ->rowCount();
  if (!$check) {
    $style = db_select('sweaver_style_draft', 's')
      ->fields('s')
      ->condition('style_id', $style_id, '=')
      ->execute()
      ->fetchObject();
    $style->active = 2;
    drupal_write_record('sweaver_style', $style);
  }
  else {
    db_update('sweaver_style')
      ->fields(array(
      'active' => 2,
    ))
      ->condition('style_id', $style_id, '=')
      ->execute();
    drupal_set_message(t('Style enabled'));
    drupal_goto('admin/config/user-interface/sweaver/styles');
  }
}