1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* Exposes API endpoints for Message entities |
4
|
|
|
*/ |
5
|
|
|
|
6
|
|
|
elgg_ws_expose_function( |
7
|
|
|
"get.message", |
8
|
|
|
"get_message", |
9
|
|
|
array( |
10
|
|
|
"user" => array('type' => 'string', 'required' => true), |
11
|
|
|
"guid" => array('type' => 'int', 'required' => true), |
12
|
|
|
"lang" => array('type' => 'string', 'required' => false, 'default' => "en") |
13
|
|
|
), |
14
|
|
|
'Retrieves a message based on user id and message id', |
15
|
|
|
'POST', |
16
|
|
|
true, |
17
|
|
|
false |
18
|
|
|
); |
19
|
|
|
|
20
|
|
|
elgg_ws_expose_function( |
21
|
|
|
"get.messages", |
22
|
|
|
"get_messages", |
23
|
|
|
array( |
24
|
|
|
"user" => array('type' => 'string', 'required' => true), |
25
|
|
|
"limit" => array('type' => 'int', 'required' => false, 'default' => 10), |
26
|
|
|
"offset" => array('type' => 'int', 'required' => false, 'default' => 0), |
27
|
|
|
"lang" => array('type' => 'string', 'required' => false, 'default' => "en") |
28
|
|
|
), |
29
|
|
|
'Retrieves a user\'s messages based on user id', |
30
|
|
|
'POST', |
31
|
|
|
true, |
32
|
|
|
false |
33
|
|
|
); |
34
|
|
|
|
35
|
|
|
elgg_ws_expose_function( |
36
|
|
|
"get.messagescount", |
37
|
|
|
"get_messages_count", |
38
|
|
|
array( |
39
|
|
|
"user" => array('type' => 'string', 'required' => true), |
40
|
|
|
"lang" => array('type' => 'string', 'required' => false, 'default' => "en") |
41
|
|
|
), |
42
|
|
|
'Retrieves a user\'s unread message count based on user id', |
43
|
|
|
'POST', |
44
|
|
|
true, |
45
|
|
|
false |
46
|
|
|
); |
47
|
|
|
|
48
|
|
|
elgg_ws_expose_function( |
49
|
|
|
"get.sentmessages", |
50
|
|
|
"get_sent_messages", |
51
|
|
|
array( |
52
|
|
|
"user" => array('type' => 'string', 'required' => true), |
53
|
|
|
"limit" => array('type' => 'int', 'required' => false, 'default' => 10), |
54
|
|
|
"offset" => array('type' => 'int', 'required' => false, 'default' => 0), |
55
|
|
|
"lang" => array('type' => 'string', 'required' => false, 'default' => "en") |
56
|
|
|
), |
57
|
|
|
'Retrieves a user\'s sent messages based on user id', |
58
|
|
|
'POST', |
59
|
|
|
true, |
60
|
|
|
false |
61
|
|
|
); |
62
|
|
|
|
63
|
|
|
elgg_ws_expose_function( |
64
|
|
|
"get.sentmessagescount", |
65
|
|
|
"get_sent_messages_count", |
66
|
|
|
array( |
67
|
|
|
"user" => array('type' => 'string', 'required' => true), |
68
|
|
|
"lang" => array('type' => 'string', 'required' => false, 'default' => "en") |
69
|
|
|
), |
70
|
|
|
'Retrieves a user\'s unread sent messages count based on user id', |
71
|
|
|
'POST', |
72
|
|
|
true, |
73
|
|
|
false |
74
|
|
|
); |
75
|
|
|
|
76
|
|
|
|
77
|
|
|
elgg_ws_expose_function( |
78
|
|
|
"get.notifications", |
79
|
|
|
"get_notifications", |
80
|
|
|
array( |
81
|
|
|
"user" => array('type' => 'string', 'required' => true), |
82
|
|
|
"limit" => array('type' => 'int', 'required' => false, 'default' => 10), |
83
|
|
|
"offset" => array('type' => 'int', 'required' => false, 'default' => 0), |
84
|
|
|
"lang" => array('type' => 'string', 'required' => false, 'default' => "en") |
85
|
|
|
), |
86
|
|
|
'Retrieves a user\'s notification messages based on user id', |
87
|
|
|
'POST', |
88
|
|
|
true, |
89
|
|
|
false |
90
|
|
|
); |
91
|
|
|
|
92
|
|
|
elgg_ws_expose_function( |
93
|
|
|
"get.notificationscount", |
94
|
|
|
"get_notifications_count", |
95
|
|
|
array( |
96
|
|
|
"user" => array('type' => 'string', 'required' => true), |
97
|
|
|
"lang" => array('type' => 'string', 'required' => false, 'default' => "en") |
98
|
|
|
), |
99
|
|
|
'Retrieves a user\'s unread notification message count based on user id', |
100
|
|
|
'POST', |
101
|
|
|
true, |
102
|
|
|
false |
103
|
|
|
); |
104
|
|
|
|
105
|
|
|
elgg_ws_expose_function( |
106
|
|
|
"send.message", |
107
|
|
|
"send_message", |
108
|
|
|
array( |
109
|
|
|
"fromuser" => array('type' => 'string', 'required' => true), |
110
|
|
|
"touser" => array('type' => 'string', 'required' => true), |
111
|
|
|
"message" => array('type' => 'string', 'required' => true), |
112
|
|
|
"lang" => array('type' => 'string', 'required' => false, 'default' => "en") |
113
|
|
|
), |
114
|
|
|
'Submits a message based on "from" user id and "to" user id', |
115
|
|
|
'POST', |
116
|
|
|
true, |
117
|
|
|
false |
118
|
|
|
); |
119
|
|
|
|
120
|
|
|
elgg_ws_expose_function( |
121
|
|
|
"reply.message", |
122
|
|
|
"reply_message", |
123
|
|
|
array( |
124
|
|
|
"user" => array('type' => 'string', 'required' => true), |
125
|
|
|
"message" => array('type' => 'string', 'required' => true), |
126
|
|
|
"guid" => array('type' => 'int', 'required' => false, 'default' => 0), |
127
|
|
|
"lang" => array('type' => 'string', 'required' => false, 'default' => "en") |
128
|
|
|
), |
129
|
|
|
'Submits a reply to a message based on user id and message id', |
130
|
|
|
'POST', |
131
|
|
|
true, |
132
|
|
|
false |
133
|
|
|
); |
134
|
|
|
|
135
|
|
|
function get_message($user, $guid, $lang) |
136
|
|
|
{ |
137
|
|
|
$user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user)); |
138
|
|
|
if (!$user_entity) { |
139
|
|
|
return "User was not found. Please try a different GUID, username, or email address"; |
140
|
|
|
} |
141
|
|
|
if (!$user_entity instanceof ElggUser) { |
142
|
|
|
return "Invalid user. Please try a different GUID, username, or email address"; |
143
|
|
|
} |
144
|
|
|
|
145
|
|
|
if (!elgg_is_logged_in()) { |
146
|
|
|
login($user_entity); |
147
|
|
|
} |
148
|
|
|
|
149
|
|
|
$messages = elgg_list_entities(array( |
150
|
|
|
'type' => 'object', |
151
|
|
|
'subtype' => 'messages', |
152
|
|
|
'guid' => $guid |
153
|
|
|
)); |
154
|
|
|
$message = json_decode($messages)[0]; |
155
|
|
|
if (!$message) { |
156
|
|
|
return "Message was not found. Please try a different GUID"; |
157
|
|
|
} |
158
|
|
|
if ($message->subtype !== "messages") { |
159
|
|
|
return "Invalid message. Please try a different GUID"; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
$likes = elgg_get_annotations(array( |
163
|
|
|
'guid' => $message->guid, |
164
|
|
|
'annotation_name' => 'likes' |
165
|
|
|
)); |
166
|
|
|
$message->likes = count($likes); |
167
|
|
|
|
168
|
|
|
$liked = elgg_get_annotations(array( |
169
|
|
|
'guid' => $message->guid, |
170
|
|
|
'annotation_owner_guid' => $user_entity->guid, |
171
|
|
|
'annotation_name' => 'likes' |
172
|
|
|
)); |
173
|
|
|
$message->liked = count($liked) > 0; |
174
|
|
|
|
175
|
|
|
$messageObj = get_entity($message->guid); |
176
|
|
|
$message->read = intval($messageObj->readYet); |
177
|
|
|
|
178
|
|
|
$message->fromUserDetails = get_user_block($messageObj->fromId, $lang); |
179
|
|
|
$message->toUserDetails = get_user_block($messageObj->toId, $lang); |
180
|
|
|
|
181
|
|
|
$message->description = utf8_decode($message->description); |
182
|
|
|
$message->description = str_replace(array("<html>", "</html>", "<body>", "</body>"), "", $message->description); |
183
|
|
|
|
184
|
|
|
// $message->description2 = strip_tags(utf8_decode($message->description)); |
185
|
|
|
|
186
|
|
|
return $message; |
187
|
|
|
} |
188
|
|
|
|
189
|
|
View Code Duplication |
function get_messages($user, $limit, $offset, $lang) |
190
|
|
|
{ |
191
|
|
|
$user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user)); |
192
|
|
|
if (!$user_entity) { |
193
|
|
|
return "User was not found. Please try a different GUID, username, or email address"; |
194
|
|
|
} |
195
|
|
|
if (!$user_entity instanceof ElggUser) { |
196
|
|
|
return "Invalid user. Please try a different GUID, username, or email address"; |
197
|
|
|
} |
198
|
|
|
|
199
|
|
|
if (!elgg_is_logged_in()) { |
200
|
|
|
login($user_entity); |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
$messages = elgg_list_entities_from_metadata(array( |
204
|
|
|
"type" => "object", |
205
|
|
|
"subtype" => "messages", |
206
|
|
|
'metadata_name_value_pair' => array( |
207
|
|
|
array('name' => 'toId', 'value' => $user_entity->guid, 'operand' => '='), |
208
|
|
|
array('name' => 'fromId', 'value' => 1, 'operand' => '!=') |
209
|
|
|
), |
210
|
|
|
"limit" => $limit, |
211
|
|
|
"offset" => $offset |
212
|
|
|
)); |
213
|
|
|
$messages = json_decode($messages); |
214
|
|
|
|
215
|
|
|
foreach ($messages as $object) { |
216
|
|
|
$messageObj = get_entity($object->guid); |
217
|
|
|
$object->read = intval($messageObj->readYet); |
218
|
|
|
|
219
|
|
|
$object->fromUserDetails = get_user_block($messageObj->fromId, $lang); |
220
|
|
|
$object->toUserDetails = get_user_block($messageObj->toId, $lang); |
221
|
|
|
|
222
|
|
|
$object->description = utf8_decode($object->description); |
223
|
|
|
$object->description = str_replace(array("<html>", "</html>", "<body>", "</body>"), "", $object->description); |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
return $messages; |
227
|
|
|
} |
228
|
|
|
|
229
|
|
View Code Duplication |
function get_messages_count($user, $lang) |
230
|
|
|
{ |
231
|
|
|
$user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user)); |
232
|
|
|
if (!$user_entity) { |
233
|
|
|
return "User was not found. Please try a different GUID, username, or email address"; |
234
|
|
|
} |
235
|
|
|
if (!$user_entity instanceof ElggUser) { |
236
|
|
|
return "Invalid user. Please try a different GUID, username, or email address"; |
237
|
|
|
} |
238
|
|
|
|
239
|
|
|
if (!elgg_is_logged_in()) { |
240
|
|
|
login($user_entity); |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
$messages = elgg_list_entities_from_metadata(array( |
244
|
|
|
"type" => "object", |
245
|
|
|
"subtype" => "messages", |
246
|
|
|
'metadata_name_value_pair' => array( |
247
|
|
|
array('name' => 'toId', 'value' => $user_entity->guid, 'operand' => '='), |
248
|
|
|
array('name' => 'fromId', 'value' => 1, 'operand' => '!=') |
249
|
|
|
) |
250
|
|
|
)); |
251
|
|
|
$messages = json_decode($messages); |
252
|
|
|
|
253
|
|
|
$unread_count = 0; |
254
|
|
|
|
255
|
|
|
foreach ($messages as $object) { |
256
|
|
|
if ($object->read) { |
257
|
|
|
$unread_count++; |
258
|
|
|
} |
259
|
|
|
} |
260
|
|
|
|
261
|
|
|
return $unread_count; |
262
|
|
|
} |
263
|
|
|
|
264
|
|
|
function get_sent_messages($user, $limit, $offset, $lang) |
265
|
|
|
{ |
266
|
|
|
$user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user)); |
267
|
|
|
if (!$user_entity) { |
268
|
|
|
return "User was not found. Please try a different GUID, username, or email address"; |
269
|
|
|
} |
270
|
|
|
if (!$user_entity instanceof ElggUser) { |
271
|
|
|
return "Invalid user. Please try a different GUID, username, or email address"; |
272
|
|
|
} |
273
|
|
|
|
274
|
|
|
if (!elgg_is_logged_in()) { |
275
|
|
|
login($user_entity); |
276
|
|
|
} |
277
|
|
|
|
278
|
|
|
$messages = elgg_list_entities_from_metadata(array( |
279
|
|
|
"type" => "object", |
280
|
|
|
"subtype" => "messages", |
281
|
|
|
"metadata_name" => "fromId", |
282
|
|
|
"metadata_value" => $user_entity->guid, |
283
|
|
|
"owner_guid" => $user_entity->guid, |
284
|
|
|
"limit" => $limit, |
285
|
|
|
"offset" => $offset |
286
|
|
|
)); |
287
|
|
|
$messages = json_decode($messages); |
288
|
|
|
|
289
|
|
|
foreach ($messages as $object) { |
290
|
|
|
$messageObj = get_entity($object->guid); |
291
|
|
|
$object->read = intval($messageObj->readYet); |
292
|
|
|
|
293
|
|
|
$object->fromUserDetails = get_user_block($messageObj->fromId, $lang); |
294
|
|
|
$object->toUserDetails = get_user_block($messageObj->toId, $lang); |
295
|
|
|
|
296
|
|
|
$object->description = utf8_decode($object->description); |
297
|
|
|
$object->description = str_replace(array("<html>", "</html>", "<body>", "</body>"), "", $object->description); |
298
|
|
|
} |
299
|
|
|
|
300
|
|
|
return $messages; |
301
|
|
|
} |
302
|
|
|
|
303
|
|
|
function get_sent_messages_count($user, $lang) |
304
|
|
|
{ |
305
|
|
|
$user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user)); |
306
|
|
|
if (!$user_entity) { |
307
|
|
|
return "User was not found. Please try a different GUID, username, or email address"; |
308
|
|
|
} |
309
|
|
|
if (!$user_entity instanceof ElggUser) { |
310
|
|
|
return "Invalid user. Please try a different GUID, username, or email address"; |
311
|
|
|
} |
312
|
|
|
|
313
|
|
|
if (!elgg_is_logged_in()) { |
314
|
|
|
login($user_entity); |
315
|
|
|
} |
316
|
|
|
|
317
|
|
|
$messages = elgg_list_entities_from_metadata(array( |
318
|
|
|
"type" => "object", |
319
|
|
|
"subtype" => "messages", |
320
|
|
|
"metadata_name" => "fromId", |
321
|
|
|
"metadata_value" => $user_entity->guid, |
322
|
|
|
"owner_guid" => $user_entity->guid |
323
|
|
|
)); |
324
|
|
|
$messages = json_decode($messages); |
325
|
|
|
|
326
|
|
|
$unread_count = 0; |
327
|
|
|
|
328
|
|
|
foreach ($messages as $object) { |
329
|
|
|
if ($object->read) { |
330
|
|
|
$unread_count++; |
331
|
|
|
} |
332
|
|
|
} |
333
|
|
|
|
334
|
|
|
return $unread_count; |
335
|
|
|
} |
336
|
|
|
|
337
|
|
View Code Duplication |
function get_notifications($user, $limit, $offset, $lang) |
338
|
|
|
{ |
339
|
|
|
$user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user)); |
340
|
|
|
if (!$user_entity) { |
341
|
|
|
return "User was not found. Please try a different GUID, username, or email address"; |
342
|
|
|
} |
343
|
|
|
if (!$user_entity instanceof ElggUser) { |
344
|
|
|
return "Invalid user. Please try a different GUID, username, or email address"; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
if (!elgg_is_logged_in()) { |
348
|
|
|
login($user_entity); |
349
|
|
|
} |
350
|
|
|
|
351
|
|
|
$messages = elgg_list_entities_from_metadata(array( |
352
|
|
|
"type" => "object", |
353
|
|
|
"subtype" => "messages", |
354
|
|
|
'metadata_name_value_pair' => array( |
355
|
|
|
array('name' => 'toId', 'value' => $user_entity->guid, 'operand' => '='), |
356
|
|
|
array('name' => 'fromId', 'value' => 1, 'operand' => '=') |
357
|
|
|
), |
358
|
|
|
"limit" => $limit, |
359
|
|
|
"offset" => $offset |
360
|
|
|
)); |
361
|
|
|
$messages = json_decode($messages); |
362
|
|
|
|
363
|
|
|
foreach ($messages as $object) { |
364
|
|
|
$messageObj = get_entity($object->guid); |
365
|
|
|
$object->read = intval($messageObj->readYet); |
366
|
|
|
|
367
|
|
|
$object->fromUserDetails = get_user_block($messageObj->fromId, $lang); |
368
|
|
|
$object->toUserDetails = get_user_block($messageObj->toId, $lang); |
369
|
|
|
|
370
|
|
|
$object->description = utf8_decode($object->description); |
371
|
|
|
$object->description = str_replace(array("<html>", "</html>", "<body>", "</body>"), "", $object->description); |
372
|
|
|
} |
373
|
|
|
|
374
|
|
|
return $messages; |
375
|
|
|
} |
376
|
|
|
|
377
|
|
View Code Duplication |
function get_notifications_count($user, $lang) |
378
|
|
|
{ |
379
|
|
|
$user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user)); |
380
|
|
|
if (!$user_entity) { |
381
|
|
|
return "User was not found. Please try a different GUID, username, or email address"; |
382
|
|
|
} |
383
|
|
|
if (!$user_entity instanceof ElggUser) { |
384
|
|
|
return "Invalid user. Please try a different GUID, username, or email address"; |
385
|
|
|
} |
386
|
|
|
|
387
|
|
|
if (!elgg_is_logged_in()) { |
388
|
|
|
login($user_entity); |
389
|
|
|
} |
390
|
|
|
|
391
|
|
|
$messages = elgg_list_entities_from_metadata(array( |
392
|
|
|
"type" => "object", |
393
|
|
|
"subtype" => "messages", |
394
|
|
|
'metadata_name_value_pair' => array( |
395
|
|
|
array('name' => 'toId', 'value' => $user_entity->guid, 'operand' => '='), |
396
|
|
|
array('name' => 'fromId', 'value' => 1, 'operand' => '=') |
397
|
|
|
) |
398
|
|
|
)); |
399
|
|
|
$messages = json_decode($messages); |
400
|
|
|
|
401
|
|
|
$unread_count = 0; |
402
|
|
|
|
403
|
|
|
foreach ($messages as $object) { |
404
|
|
|
if ($object->read) { |
405
|
|
|
$unread_count++; |
406
|
|
|
} |
407
|
|
|
} |
408
|
|
|
|
409
|
|
|
return $unread_count; |
410
|
|
|
} |
411
|
|
|
|
412
|
|
|
function send_message($fromuser, $touser, $subject, $message, $lang) |
413
|
|
|
{ |
414
|
|
|
$from_user_entity = is_numeric($fromuser) ? get_user($fromuser) : (strpos($fromuser, '@') !== false ? get_user_by_email($fromuser)[0] : get_user_by_username($fromuser)); |
415
|
|
|
if (!$from_user_entity) { |
416
|
|
|
return "\"From\" User was not found. Please try a different GUID, username, or email address"; |
417
|
|
|
} |
418
|
|
|
if (!$from_user_entity instanceof ElggUser) { |
419
|
|
|
return "Invalid \"from\" user. Please try a different GUID, username, or email address"; |
420
|
|
|
} |
421
|
|
|
|
422
|
|
|
$to_user_entity = is_numeric($touser) ? get_user($touser) : (strpos($touser, '@') !== false ? get_user_by_email($touser)[0] : get_user_by_username($touser)); |
423
|
|
|
if (!$to_user_entity) { |
424
|
|
|
return "\"To\" User was not found. Please try a different GUID, username, or email address"; |
425
|
|
|
} |
426
|
|
|
if (!$to_user_entity instanceof ElggUser) { |
427
|
|
|
return "Invalid \"to\" user. Please try a different GUID, username, or email address"; |
428
|
|
|
} |
429
|
|
|
|
430
|
|
|
if (trim($subject) == "") { |
431
|
|
|
return "A subject must be provided to send a message"; |
432
|
|
|
} |
433
|
|
|
if (trim($message) == "") { |
434
|
|
|
return "A message must be provided to send a message"; |
435
|
|
|
} |
436
|
|
|
|
437
|
|
View Code Duplication |
if (elgg_is_active_plugin('cp_notifications')) { |
438
|
|
|
$messageData = array( |
439
|
|
|
'cp_from' => $from_user_entity, |
440
|
|
|
'cp_to' => $to_user_entity, |
441
|
|
|
'cp_topic_title' => $subject, |
442
|
|
|
'cp_topic_description' => $message, |
443
|
|
|
'cp_msg_type' => 'cp_site_msg_type', |
444
|
|
|
'cp_topic_url' => elgg_get_site_url() . '/messages/inbox/', |
445
|
|
|
); |
446
|
|
|
$result = elgg_trigger_plugin_hook('cp_overwrite_notification', 'all', $messageData); |
447
|
|
|
$result = true; |
448
|
|
|
} else { |
449
|
|
|
$result = messages_send($subject, $message, $to_user_entity->guid, $from_user_entity->guid); |
450
|
|
|
} |
451
|
|
|
|
452
|
|
|
if (!$result) { |
453
|
|
|
return elgg_echo("messages:error"); |
454
|
|
|
} |
455
|
|
|
|
456
|
|
|
return elgg_echo("messages:posted"); |
457
|
|
|
} |
458
|
|
|
|
459
|
|
|
function reply_message($user, $message, $guid, $lang) |
460
|
|
|
{ |
461
|
|
|
$from_user_entity = is_numeric($user) ? get_user($user) : (strpos($user, '@') !== false ? get_user_by_email($user)[0] : get_user_by_username($user)); |
462
|
|
|
if (!$from_user_entity) { |
463
|
|
|
return "User was not found. Please try a different GUID, username, or email address"; |
464
|
|
|
} |
465
|
|
|
if (!$from_user_entity instanceof ElggUser) { |
466
|
|
|
return "Invalid user. Please try a different GUID, username, or email address"; |
467
|
|
|
} |
468
|
|
|
|
469
|
|
|
$entity = get_entity($guid); |
470
|
|
|
if (!$entity) { |
471
|
|
|
return "Message was not found. Please try a different GUID"; |
472
|
|
|
} |
473
|
|
|
if (!$entity->subtype !== "messages") { |
474
|
|
|
return "Invalid message. Please try a different GUID"; |
475
|
|
|
} |
476
|
|
|
|
477
|
|
|
$to_user_entity = get_user($entity->fromId); |
478
|
|
|
|
479
|
|
|
if (trim($message) == "") { |
480
|
|
|
return "A message must be provided to send a message"; |
481
|
|
|
} |
482
|
|
|
|
483
|
|
View Code Duplication |
if (elgg_is_active_plugin('cp_notifications')) { |
484
|
|
|
$messageData = array( |
485
|
|
|
'cp_from' => $from_user_entity, |
486
|
|
|
'cp_to' => $to_user_entity, |
487
|
|
|
'cp_topic_title' => $entity->title, |
488
|
|
|
'cp_topic_description' => $message, |
489
|
|
|
'cp_msg_type' => 'cp_site_msg_type', |
490
|
|
|
'cp_topic_url' => elgg_get_site_url() . '/messages/inbox/', |
491
|
|
|
); |
492
|
|
|
$result = elgg_trigger_plugin_hook('cp_overwrite_notification', 'all', $messageData); |
493
|
|
|
$result = true; |
494
|
|
|
} else { |
495
|
|
|
$result = messages_send($entity->title, $message, $to_user_entity->guid, $from_user_entity->guid, $guid); |
496
|
|
|
} |
497
|
|
|
|
498
|
|
|
if (!$result) { |
499
|
|
|
return elgg_echo("messages:error"); |
500
|
|
|
} |
501
|
|
|
|
502
|
|
|
return elgg_echo("messages:posted"); |
503
|
|
|
} |
504
|
|
|
|