Code Duplication    Length = 12-16 lines in 3 locations

mod/cp_notifications/start.php 3 locations

@@ 994-1006 (lines=13) @@
991
992
			if ($object->access_id == 1 || $object->access_id == 2 || $content_entity->getType() === 'group' || $action_type === 'post_likes') {
993
994
				if (strcmp(elgg_get_plugin_user_setting('cpn_set_digest', $to_recipient->guid,'cp_notifications'),'set_digest_yes') == 0)
995
					create_digest($author, $action_type, $content_entity, $to_recipient);
996
997
				else {
998
					$template = elgg_view('cp_notifications/email_template', $message);
999
1000
					if (elgg_is_active_plugin('phpmailer')) {
1001
1002
						phpmailer_send( $to_recipient->email, $to_recipient->name, $subject, $template, NULL, true );
1003
					}
1004
					else
1005
						mail($to_recipient->email, $subject, $template, cp_get_headers());
1006
				}
1007
			}
1008
		}
1009
	}
@@ 1174-1189 (lines=16) @@
1171
					$template = elgg_view('cp_notifications/email_template', $message);
1172
					$user_setting = elgg_get_plugin_user_setting('cpn_mentions_email', $mentioned_user->guid, 'cp_notifications');
1173
1174
					if (strcmp($user_setting, 'mentions_email') == 0) {
1175
						$user_setting = elgg_get_plugin_user_setting('cpn_set_digest', $mentioned_user->guid, 'cp_notifications');
1176
1177
						// send digest
1178
						if (strcmp($user_setting, "set_digest_yes") == 0) {
1179
							create_digest($object->getOwnerEntity(), "cp_mention", $object, $mentioned_user);
1180
1181
						// send email and site notification
1182
						} else {
1183
1184
							if (elgg_is_active_plugin('phpmailer'))
1185
								phpmailer_send( $mentioned_user->email, $mentioned_user->name, $subject, $template, NULL, true );
1186
							else
1187
								mail($mentioned_user->email,$subject,$template,cp_get_headers());
1188
						}
1189
					}
1190
1191
					$user_setting = elgg_get_plugin_user_setting('cpn_mentions_site', $mentioned_user->guid, 'cp_notifications');
1192
					$site_template = elgg_view('cp_notifications/site_template', $message);
@@ 1441-1452 (lines=12) @@
1438
				
1439
					if (has_access_to_entity($object, $recipient_user) && $object->access_id != 0) {
1440
				
1441
					if (strcmp($user_setting, "set_digest_yes") == 0) {
1442
						create_digest($author, $switch_case, $content_entity, get_entity($to_recipient->guid));
1443
				
1444
					} else {
1445
				
1446
						$template = elgg_view('cp_notifications/email_template', $message);
1447
				
1448
						if (elgg_is_active_plugin('phpmailer'))
1449
							phpmailer_send( $to_recipient->email, $to_recipient->name, $subject, $template, NULL, true );
1450
						else
1451
							mail($to_recipient->email,$subject,$template,cp_get_headers());
1452
					}
1453
				}
1454
			
1455