messages.php 709 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * Messages helper functions
  4. *
  5. * @package ElggMessages
  6. */
  7. /**
  8. * Prepare the compose form variables
  9. *
  10. * @return array
  11. */
  12. function messages_prepare_form_vars($recipient_guid = 0) {
  13. $recipient_username = '';
  14. $recipient = get_entity($recipient_guid);
  15. if (elgg_instanceof($recipient, 'user')) {
  16. $recipient_username = $recipient->username;
  17. }
  18. // input names => defaults
  19. $values = array(
  20. 'subject' => '',
  21. 'body' => '',
  22. 'recipient_username' => $recipient_username,
  23. );
  24. if (elgg_is_sticky_form('messages')) {
  25. foreach (array_keys($values) as $field) {
  26. $values[$field] = elgg_get_sticky_value('messages', $field);
  27. }
  28. }
  29. elgg_clear_sticky_form('messages');
  30. return $values;
  31. }