You are here

private function HeartbeatActivity::save_locale in Heartbeat 6.4

Same name and namespace in other branches
  1. 6.3 includes/heartbeatactivity.inc \HeartbeatActivity::save_locale()

Save activity log with multilingual content and multilingual parts to pre-translate

Parameters

array $raw_args:

1 call to HeartbeatActivity::save_locale()
HeartbeatActivity::save in includes/heartbeatactivity.inc
Public function to save activity to database

File

includes/heartbeatactivity.inc, line 360
HeartbeatActivity object Defines one heartbeat activity object.

Class

HeartbeatActivity
Class defines an activity message object

Code

private function save_locale($raw_args = array()) {
  $logged = FALSE;
  $args = $this
    ->rebuild_arguments($raw_args, TRUE);
  $locale = $args['locale'];
  unset($args['locale']);

  // Save activity by logging a row for each active language
  // Translations only when locale exists
  $languages = locale_language_list();
  $tuaid = NULL;
  foreach ($languages as $language => $human_language) {

    // preprocess multilingual message "parts"
    // for all flagged token replacements
    foreach ($this->variables as $key => $value) {
      if (isset($locale[$key])) {
        $amp_token = str_replace("#", "!", $key);
        $args[$amp_token] = locale($locale[$key], $language);
      }
    }
    $uaid = $this
      ->log_message($args, $language);

    // Each language has the first uaid (user activity id) as
    // tuaid (translated user activity id)
    if ($uaid && !isset($tuaid)) {
      $tuaid = $uaid;
    }
    db_query("INSERT INTO {heartbeat_translations} SET tuaid=%d, uaid=%d", $tuaid, $uaid);
  }
  $this->uaid = $tuaid;
  return $tuaid;
}