You are here

public function dsDisplay::save in Display Suite 6.3

Save this display to the database

File

includes/dsDisplay.php, line 106
Class definition for a Display Suite Display object

Class

dsDisplay
The Display Suite Display object

Code

public function save() {
  $success = FALSE;

  // Iterate over fields and ditch those which are hidden.
  if (!empty($this->settings['fields'])) {
    foreach ($this->settings['fields'] as $field_key => $field_value) {
      if ($field_value['region'] == 'disabled') {
        unset($this->settings['fields'][$field_key]);
      }
    }
  }
  $this->settings = serialize($this->settings);
  if (isset($this->dsid)) {
    $op = 'update';
  }
  else {
    $op = 'create';
  }
  switch ($op) {
    case 'create':
      $result = drupal_write_record('ds_settings', $this);
      break;
    case 'update':
      $result = drupal_write_record('ds_settings', $this, 'dsid');
      break;
  }
  if ($result) {
    switch ($result) {
      case SAVED_NEW:
      case SAVED_UPDATED:
        $success = TRUE;
        $this
          ->load($this->name);

        // Reload to get the dsid
        break;
    }
  }
  if (isset($result) && $result == TRUE) {
    return TRUE;
  }
  return FALSE;
}