| @@ 51-65 (lines=15) @@ | ||
| 48 | } |
|
| 49 | ||
| 50 | // cyu - 03/16/2016: modified to improve notifications |
|
| 51 | if (elgg_is_active_plugin('cp_notifications')) { |
|
| 52 | $from_user = elgg_get_logged_in_user_entity(); |
|
| 53 | $message = array( |
|
| 54 | 'cp_from' => $from_user, |
|
| 55 | 'cp_to' => $user, |
|
| 56 | 'cp_topic_title' => $subject, |
|
| 57 | 'cp_topic_description' => $body, |
|
| 58 | 'cp_msg_type' => 'cp_site_msg_type', |
|
| 59 | 'cp_topic_url' => elgg_get_site_url().'/messages/inbox/', |
|
| 60 | ); |
|
| 61 | $result = elgg_trigger_plugin_hook('cp_overwrite_notification', 'all', $message); |
|
| 62 | $result = true; |
|
| 63 | } else |
|
| 64 | // Otherwise, 'send' the message |
|
| 65 | $result = messages_send($subject, $body, $user->guid, 0, $original_msg_guid); |
|
| 66 | ||
| 67 | ||
| 68 | ||
| @@ 378-391 (lines=14) @@ | ||
| 375 | if( trim($subject) == "" ) return "A subject must be provided to send a message"; |
|
| 376 | if( trim($message) == "" ) return "A message must be provided to send a message"; |
|
| 377 | ||
| 378 | if( elgg_is_active_plugin('cp_notifications') ){ |
|
| 379 | $messageData = array( |
|
| 380 | 'cp_from' => $from_user_entity, |
|
| 381 | 'cp_to' => $to_user_entity, |
|
| 382 | 'cp_topic_title' => $subject, |
|
| 383 | 'cp_topic_description' => $message, |
|
| 384 | 'cp_msg_type' => 'cp_site_msg_type', |
|
| 385 | 'cp_topic_url' => elgg_get_site_url() . '/messages/inbox/', |
|
| 386 | ); |
|
| 387 | $result = elgg_trigger_plugin_hook('cp_overwrite_notification', 'all', $messageData); |
|
| 388 | $result = true; |
|
| 389 | } else { |
|
| 390 | $result = messages_send($subject, $message, $to_user_entity->guid, $from_user_entity->guid); |
|
| 391 | } |
|
| 392 | ||
| 393 | if( !$result ) return elgg_echo("messages:error"); |
|
| 394 | ||
| @@ 411-424 (lines=14) @@ | ||
| 408 | ||
| 409 | if( trim($message) == "" ) return "A message must be provided to send a message"; |
|
| 410 | ||
| 411 | if( elgg_is_active_plugin('cp_notifications') ){ |
|
| 412 | $messageData = array( |
|
| 413 | 'cp_from' => $from_user_entity, |
|
| 414 | 'cp_to' => $to_user_entity, |
|
| 415 | 'cp_topic_title' => $entity->title, |
|
| 416 | 'cp_topic_description' => $message, |
|
| 417 | 'cp_msg_type' => 'cp_site_msg_type', |
|
| 418 | 'cp_topic_url' => elgg_get_site_url() . '/messages/inbox/', |
|
| 419 | ); |
|
| 420 | $result = elgg_trigger_plugin_hook('cp_overwrite_notification', 'all', $messageData); |
|
| 421 | $result = true; |
|
| 422 | } else { |
|
| 423 | $result = messages_send($entity->title, $message, $to_user_entity->guid, $from_user_entity->guid, $guid); |
|
| 424 | } |
|
| 425 | ||
| 426 | if( !$result ) return elgg_echo("messages:error"); |
|
| 427 | ||