You are here

public function NodeRegistrationNodeSettings::update in Node registration 7

Updates this node's registration settings.

File

includes/node_registration.node_settings.inc, line 299
Node settings class.

Class

NodeRegistrationNodeSettings
Node settings class.

Code

public function update($settings = NULL) {

  // If no argument was passed, persist the current settings.
  if ($settings === NULL) {

    // Only save if this node already had custom settings. Don't ALWAYS copy node type
    // settings into it.
    if (!$this->more_settings) {
      return;
    }
    $settings = get_object_vars($this);
  }
  $allowed_native = array(
    'nid' => 0,
    'capacity' => 1,
    'status' => 1,
    'private_fields' => 1,
  );
  $allowed_extra = _node_registration_defaults();
  $extra = $this->more_settings;
  $native = array();
  foreach ($settings as $name => $value) {
    if (isset($allowed_native[$name])) {
      if ($allowed_native[$name]) {
        $native[$name] = $value;
      }
    }
    else {
      if (isset($allowed_extra[$name]) || strpos($name, 'extra_') === 0) {
        $extra[$name] = $value;
      }
    }
  }
  $native['settings'] = serialize($extra);
  return db_merge('node_registration_node')
    ->key(array(
    'nid' => $this->nid,
  ))
    ->fields($native)
    ->execute();
}