From 28eeec3baac944f4fdb2104b85b052c00d09996e Mon Sep 17 00:00:00 2001
From: Ron Shimshock <ron@shimshockgroup.com>
Date: Sat, 3 Sep 2016 10:34:19 -0500
Subject: [PATCH] Duplicate system path issue

---
 admin_views.module | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/admin_views.module b/admin_views.module
index 53e726f..84fcb25 100644
--- a/admin_views.module
+++ b/admin_views.module
@@ -14,3 +14,33 @@ function admin_views_views_api() {
   );
 }
 
+/*
+ * Implements hook_menu_alter().
+ */
+function admin_views_menu_alter(&$items) {
+  // Build an array of system paths from Views displays.
+  $system_paths = array();
+  foreach (views_get_all_views() as $view) {
+    if (!$view->disabled) {
+      foreach ($view->display as $settings) {
+        if (isset($settings->display_plugin) && $settings->display_plugin == 'system') {
+          $system_paths[] = $settings->display_options['path'];
+        }
+      }
+    }
+  }
+  // Filter system paths for duplicates.
+  $duplicate_paths = array_filter(array_count_values($system_paths), function($v) { return $v > 1; });
+  // Remove extra menu access arguments from duplicate paths.
+  $message_paths = array();
+  foreach ($duplicate_paths as $path => $path_count) {
+    $message_paths[] = $path;
+    array_splice($items[$path]['access arguments'], 1);
+  }
+  // Present error message notifying that views edits are required.
+  if (!empty($message_paths)) {
+    $message = t('The following system paths exist on multiple views: <em>!paths</em>. Please disable or delete unneeded views. Access to the conflicting views will be limited until resolved.',
+      array('!paths' => implode(', ', $message_paths)));
+    drupal_set_message($message, 'error');
+  }
+}
-- 
2.9.3

