You are here

function activity_write_messages in Activity 7

Writes the provided messages to the activity tables.

Parameters

array $messages: The messages to write keyed by language and uid.

int $aid: The {activity}.aid field.

2 calls to activity_write_messages()
activity_recreate_messages in ./activity.module
Creates new messages for a set of activity records.
activity_save_activity in ./activity.module
Write all required db records for a new activity.

File

./activity.module, line 337
Records Activity across the site and surfaces that to Views.

Code

function activity_write_messages($messages, $aid) {
  foreach ($messages as $language_id => $language_messages) {
    foreach ($language_messages as $uid => $message) {

      // write the message away first to get the amid.
      $message_record = new stdClass();
      $message_record->message = $message;
      drupal_write_record('activity_messages', $message_record);

      // now save the target with the amid from above ^^.
      $target_record = array(
        'aid' => $aid,
        'uid' => $uid,
        'language' => $language_id,
        'amid' => $message_record->amid,
      );
      drupal_write_record('activity_targets', $target_record);
    }
  }
}