From 2f0c18055c213a02c376e84ea0b1df34cb7188c0 Mon Sep 17 00:00:00 2001
From: root <root@drupal24.cern.ch>
Date: Thu, 14 Dec 2017 17:11:53 +0100
Subject: [PATCH] Fix on the removal of centrally managed modules

---
 cern_integration.info   |  2 +-
 cern_integration.module | 10 ++++++----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/cern_integration.info b/cern_integration.info
index 5f204d0..277e15e 100644
--- a/cern_integration.info
+++ b/cern_integration.info
@@ -1,7 +1,7 @@
 name = CERN Integration
 package = CERN
 description = Provides CERN site integration for Drupal.
-version = "7.X-1.10"
+version = "7.X-1.11"
 core = 7.x
 
 dependencies[] = shib_auth
diff --git a/cern_integration.module b/cern_integration.module
index 0e63fc2..df592f4 100644
--- a/cern_integration.module
+++ b/cern_integration.module
@@ -561,12 +561,14 @@ function cern_integration_form_domain_301_redirect_admin_form_alter(&$form, &$fo
 function cern_integration_update_projects_alter(&$projects)
 {
     // Remove all centrally managed modules.
-    foreach (module_list() as $module) {
-        if (preg_match('/^sites\/all\/modules\//', drupal_get_path('module', $module))) {
-            // This works only if the module name matches the project name.
-            unset($projects[$module]);
+    foreach (system_list("module_enabled") as $module) {
+        if (preg_match('/^sites\/all\/modules\//', drupal_get_path('module', $module->name))) {
+            if(isset($module->info["project"])){
+                unset($projects[$module->info["project"]]);
+            }
         }
     }
+ 
     // Remove all centrally managed themes and their subthemes.
     $array_themes = list_themes();
     foreach ($array_themes as $theme_obj) {
-- 
GitLab