You are here

public function HeartbeatMessageTemplate::save in Heartbeat 7

save().

Function to save the template to database.

File

includes/heartbeatmessagetemplate.inc, line 193
HeartbeatMessageTemplate Template object that holds configuration for a message template. A HeartbeatActivity object will be able to have the template as composite.

Class

HeartbeatMessageTemplate
Class HeartbeatMessageTemplate

Code

public function save() {
  $this
    ->setMessageVariables();
  $fields = array(
    'message' => $this->message,
    'message_concat' => $this->message_concat,
    'attachments' => $this->attachments,
    'variables' => $this->variables,
    'description' => $this->description,
    'concat_args' => $this->concat_args,
    'perms' => (int) $this->perms,
    'disabled' => (int) $this->disabled,
  );
  if (isset($this->message_id)) {
    $fields['message_id'] = $this->message_id;
  }

  // Update a record.
  if (!empty($this->hid)) {
    $query = db_update('heartbeat_messages')
      ->condition('hid', $this->hid);
  }
  else {
    $query = db_insert('heartbeat_messages');
  }
  return $query
    ->fields($fields)
    ->execute();
}