From ece2313a84324218a44460f275c3131a7f3bd5f0 Mon Sep 17 00:00:00 2001
From: Jeremy Stoller <jstoller@cscmail.org>
Date: Mon, 15 Aug 2016 15:05:47 -0700
Subject: [PATCH] simplify_access_checks-2784555-5.patch

---
 menu_link_weight.install | 25 +++++++++++++++++++++++++
 menu_link_weight.module  |  9 +++------
 2 files changed, 28 insertions(+), 6 deletions(-)
 create mode 100644 menu_link_weight.install

diff --git a/menu_link_weight.install b/menu_link_weight.install
new file mode 100644
index 0000000..3a3cd94
--- /dev/null
+++ b/menu_link_weight.install
@@ -0,0 +1,25 @@
+<?php
+
+/**
+ * @file
+ * Install file for Menu Link Weight.
+ * */
+
+ /**
+ * Implements hook_install().
+ */
+function menu_link_weight_install() {
+  menu_link_weight_update_7000();
+}
+
+/**
+* Make the Menu Link Weight module execute later.
+*/
+function menu_link_weight_update_7000() {
+  // Make sure this module always runs after the core Menu module and allows
+  // other modules to alter menu access before executing.
+  db_update('system')
+    ->fields(array('weight' => 4))
+    ->condition('name', 'menu_link_weight')
+    ->execute();
+}
diff --git a/menu_link_weight.module b/menu_link_weight.module
index a0cf093..1b9909d 100644
--- a/menu_link_weight.module
+++ b/menu_link_weight.module
@@ -24,12 +24,9 @@ define('MENU_LINK_WEIGHT_MAX_DELTA', 50);
  * Implements hook_form_FORM_ID_alter().
  */
 function menu_link_weight_form_node_form_alter(&$form, &$form_state) {
-  if (module_exists('menu_admin_per_menu') && function_exists('_menu_admin_per_menu_filter_parent_options') && isset($form['menu']['link']['parent']) && !user_access('administer menu') && _menu_admin_per_menu_filter_parent_options($form['menu']['link'])) {
-    // Pass if the user does not have "administer menu" permission but does
-    // have permission through Menu Admin Per Menu.
-  }
-  elseif (!user_access('administer menu') || !isset($form['menu']['link'])) {
-    // Only allow users with "administer menu" permissions.
+  if (!isset($form['menu']) || (isset($form['menu']['#access']) && $form['menu']['#access'] === FALSE) || (isset($form['menu']['link']['parent']['#access']) && $form['menu']['link']['parent']['#access'] === FALSE)) {
+    // If there is no menu, or the user doesn't have access to the
+    // menu link options, then do nothing.
     return;
   }
 
-- 
2.8.1

