Code Duplication    Length = 14-15 lines in 3 locations

mod/messages/actions/messages/send.php 1 location

@@ 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

mod/gc_mobile_api/models/message.php 2 locations

@@ 437-450 (lines=14) @@
434
		return "A message must be provided to send a message";
435
	}
436
437
	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");
@@ 483-496 (lines=14) @@
480
		return "A message must be provided to send a message";
481
	}
482
483
	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");