<commit_before><?php
// $Id$

function biurnal_node_info() {
  return array(
    'biurnal' => array(
      'name' => t('Biurnal configuration node'),
      'module' => 'biurnal',
      'description' => t("This is a configuration node for biurnal"),
    )
  );
}

function biurnal_access($op, $node) {
  global $user;

  if ($op == 'create') {
    return user_access('create biurnal node');
  }

  if ($op == 'update' || $op == 'delete') {
    if (user_access('edit all biurnal nodes') || (user_access('edit own biurnal node') && ($user->uid == $node->uid))) {
      return TRUE;
    }
  }
}

function biurnal_form(&$node) {
  global $_biurnal_;
  
  $type = node_get_types('type', $node);
  $base = drupal_get_path('module', 'biurnal');

  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => check_plain($type->title_label),
    '#required' => TRUE,
    '#default_value' => $node->title,
    '#weight' => -5
  );
  
  // Add Farbtastic color picker
  drupal_add_css('misc/farbtastic/farbtastic.css', 'module', 'all', FALSE);
  drupal_add_js('misc/farbtastic/farbtastic.js');
  
  // Add custom CSS/JS
  drupal_add_css($base .'/biurnal.css', 'module', 'all', FALSE);
  drupal_add_js($base .'/biurnal.js');
  
  $themes = list_themes();
  
  foreach($themes as $theme)
  {
    if ($theme->status && $_biurnal_->theme_is_biurnal($theme->name) &&
      function_exists('gd_info') && 
      variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC) 
    {
      $form['color'] = array(
        '#type' => 'fieldset',
        '#title' => t('Color scheme for %name', array('%name'=>$theme->name)),
        '#weight' => -1,
        '#attributes' => array('class' => 'biurnal_color_scheme_form'),
        '#theme' => 'biurnal_scheme_form',
      );
      $form['color'] += biurnal_scheme_form($node, $theme);
    }
  }

  return $form;
}

function biurnal_update(&$node) {
  biurnal_insert($node,True);
}

function biurnal_insert(&$node, $is_update=False) {
  global $_biurnal_;
  
  $themes = list_themes();
  $scheme = array();
  foreach ($themes as $theme) {
    if ($theme->status && $_biurnal_->theme_is_biurnal($theme->name)) {
      $palette = $_biurnal_->get_colors_for_theme($theme->name);
      foreach( $palette as $name => $value ) {
        $field_name = 'biurnal_color_'. $theme->name .'_'. $name;
        $node->palette[$theme->name][$name] = $node->$field_name;
      }
    }
  }

  $configuration = serialize($node->palette);
  if (!$is_update) {
    db_query("INSERT INTO {biurnal_configuration} (nid, configuration) VALUES (%d, '%s')", $node->nid, $configuration);
  }
  else {
    db_query("UPDATE {biurnal_configuration} AS bc SET bc.configuration = '%s' WHERE bc.nid = %d", $configuration, $node->nid);
  }
}<commit_msg>Fixed persistent bug in biurnal. Biurnal nodes should now be correctly auto-published.<commit_after><?php
// $Id$

function biurnal_node_info() {
  return array(
    'biurnal' => array(
      'name' => t('Biurnal configuration node'),
      'module' => 'biurnal',
      'description' => t("This is a configuration node for biurnal"),
    )
  );
}

function biurnal_access($op, $node) {
  global $user;

  if ($op == 'create') {
    return user_access('create biurnal node');
  }

  if ($op == 'update' || $op == 'delete') {
    if (user_access('edit all biurnal nodes') || (user_access('edit own biurnal node') && ($user->uid == $node->uid))) {
      return TRUE;
    }
  }
}

function biurnal_form(&$node) {
  global $_biurnal_;
  
  $type = node_get_types('type', $node);
  $base = drupal_get_path('module', 'biurnal');

  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => check_plain($type->title_label),
    '#required' => TRUE,
    '#default_value' => $node->title,
    '#weight' => -5
  );
  
  // Add Farbtastic color picker
  drupal_add_css('misc/farbtastic/farbtastic.css', 'module', 'all', FALSE);
  drupal_add_js('misc/farbtastic/farbtastic.js');
  
  // Add custom CSS/JS
  drupal_add_css($base .'/biurnal.css', 'module', 'all', FALSE);
  drupal_add_js($base .'/biurnal.js');
  
  $themes = list_themes();
  
  foreach($themes as $theme)
  {
    if ($theme->status && $_biurnal_->theme_is_biurnal($theme->name) &&
      function_exists('gd_info') && 
      variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == FILE_DOWNLOADS_PUBLIC) 
    {
      $form['color'] = array(
        '#type' => 'fieldset',
        '#title' => t('Color scheme for %name', array('%name'=>$theme->name)),
        '#weight' => -1,
        '#attributes' => array('class' => 'biurnal_color_scheme_form'),
        '#theme' => 'biurnal_scheme_form',
      );
      $form['color'] += biurnal_scheme_form($node, $theme);
    }
  }

  return $form;
}

function biurnal_update(&$node) {
  biurnal_insert($node,True);
}

function biurnal_insert(&$node, $is_update=False) {
  global $_biurnal_;
  
  $themes = list_themes();
  $scheme = array();
  foreach ($themes as $theme) {
    if ($theme->status && $_biurnal_->theme_is_biurnal($theme->name)) {
      $palette = $_biurnal_->get_colors_for_theme($theme->name);
      foreach( $palette as $name => $value ) {
        $field_name = 'biurnal_color_'. $theme->name .'_'. $name;
        if (isset($node->$field_name)) { //Check this to avoid nulling palette on non-form updates
          $node->palette[$theme->name][$name] = $node->$field_name;
        }
      }
    }
  }

  $configuration = serialize($node->palette);
  if (!$is_update) {
    db_query("INSERT INTO {biurnal_configuration} (nid, configuration) VALUES (%d, '%s')", $node->nid, $configuration);
  }
  else {
    db_query("UPDATE {biurnal_configuration} AS bc SET bc.configuration = '%s' WHERE bc.nid = %d", $configuration, $node->nid);
  }
}
{'fraction_non_alphanumeric': 0.19001047851903596, 'fraction_numerical': 0.0006985679357317499, 'mean_word_length': 3.5380348652931852, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 78, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2831312', 'n_tokens_mistral': 2080, 'n_tokens_neox': 2003, 'n_words': 394}