1<?php 2/** 3 * Elgg Message board: add message action 4 */ 5 6use Elgg\Database\Clauses\OrderByClause; 7 8$message_content = get_input('message_content'); 9$owner_guid = (int) get_input('owner_guid'); 10$owner = get_user($owner_guid); 11 12if (!$owner || empty($message_content)) { 13 return elgg_error_response(elgg_echo('messageboard:blank')); 14} 15 16$result = messageboard_add(elgg_get_logged_in_user_entity(), $owner, $message_content, $owner->access_id); 17 18if ($result === false) { 19 return elgg_error_response(elgg_echo('messageboard:failure')); 20} 21 22$output = elgg_list_annotations([ 23 'annotation_name' => 'messageboard', 24 'guid' => $owner->guid, 25 'pagination' => false, 26 'order_by' => [ 27 new OrderByClause('n_table.time_created', 'DESC'), 28 new OrderByClause('n_table.id', 'DESC'), 29 ], 30 'limit' => 1, 31]); 32 33return elgg_ok_response($output, elgg_echo('messageboard:posted')); 34