Code Duplication    Length = 19-23 lines in 2 locations

mod/cp_notifications/start.php 2 locations

@@ 750-768 (lines=19) @@
747
			$get_error_info = 'blog revision or published';
748
749
			$watchers = get_subscribers($dbprefix, $author_id, $content_id);
750
			foreach ($watchers as $watcher) {
751
				$message['user_name'] = $watcher->username;
752
753
				$template = elgg_view('cp_notifications/email_template', $message);
754
755
				$recipient_user = get_user($watcher->guid);
756
757
				if (has_access_to_entity($entity, $recipient_user) && $entity->access_id != 0) {
758
					if (strcmp(elgg_get_plugin_user_setting('cpn_set_digest', $watcher->guid,'cp_notifications'), 'set_digest_yes') == 0)
759
						create_digest($author, $action_type, $content_entity, get_entity($watcher->guid));
760
					else
761
						(elgg_is_active_plugin('phpmailer')) ? phpmailer_send($watcher->email, $watcher->name, $subject, $template, NULL, true) : mail($watcher->email, $subject, $template, cp_get_headers());
762
				
763
					if (check_entity_relationship($watcher->guid, 'cp_subscribed_to_site_mail', $entity->getContainerGUID()))
764
						messages_send($subject, $template, $watcher->guid, $site->guid, 0, true, false);
765
				}
766
			}
767
			return true;
768
		}
769
770
771
		// checks for condition if the content being modified is a page or task
@@ 793-815 (lines=23) @@
790
791
			$watchers = get_subscribers($dbprefix, $current_user->guid, $entity->guid);
792
793
			foreach ($watchers as $watcher) {
794
				$message['user_name'] = $watcher->username;
795
				$template = elgg_view('cp_notifications/email_template', $message);
796
				$recipient_user = get_user($watcher->guid);
797
798
				if (has_access_to_entity($entity, $recipient_user) /*&& $object->access_id != 0*/) {
799
800
					if (strcmp(elgg_get_plugin_user_setting('cpn_set_digest', $watcher->guid,'cp_notifications'),'set_digest_yes') == 0) {
801
802
						create_digest($author, $action_type, $content_entity, get_entity($watcher->guid));
803
					}
804
					else {
805
806
						(elgg_is_active_plugin('phpmailer')) ? phpmailer_send( $watcher->email, $watcher->name, $subject, $template, NULL, true ) : mail($watcher->email, $subject, $template, cp_get_headers());
807
					}
808
809
810
					if (check_entity_relationship($watcher->guid, 'cp_subscribed_to_site_mail', $entity->getContainerGUID())) {
811
						$site_template = elgg_view('cp_notifications/site_template', $message);
812
						messages_send($subject, $site_template, $watcher->guid, $site->guid, 0, true, false);
813
					}
814
				}
815
			}
816
			return true;
817
		}
818