Use .info file tags[] to categorize a module as developer module

designerbrent - November 4, 2009 - 19:56
Project:Administration menu
Version:7.x-3.x-dev
Component:Code
Category:task
Priority:normal
Assigned:Unassigned
Status:needs review
Description

I'm wondering if we can add "reroute_email" as a Developer module that can be disabled via the 1 click disable in the admin_menu? I've attached a patch that does this.

reroute_email is only something that you would want running on a dev site so it would be nice to have a simple way to disable it.

AttachmentSize
admin_menu_add_reroute_email.diff219 bytes

#1

sun - November 4, 2009 - 22:04
Title:Adding reroute_email as a Developer module» Turn admin_menu_developer_modules variable into a hook
Version:6.x-3.x-dev» 7.x-3.x-dev
Category:feature request» task

It is starting to get messy.

Instead of doing that, let's simply turn this into a hook.

AttachmentSize
admin_menu.devel-modules.patch 3.46 KB

#2

Dave Reid - November 4, 2009 - 22:18

Crazy idea...let's have people put developer = TRUE in their module's info.files.

#3

sun - November 4, 2009 - 22:39

Actually, I thought of that too while implementing the hook. ;)

But would it be better?

#4

Dave Reid - November 4, 2009 - 22:41

I could this having much more re-use for other things than an admin_menu_developer_modules hook. Of course in the meantime, admin_menu could implement admin_menu_system_info_alter() for the specified modules. Also if the module has specified package = Development, it should be included.

#5

sun - November 4, 2009 - 22:46

tags[] = developer
tags[] = administration
tags[] = ...

? :)

#6

Dave Reid - November 4, 2009 - 23:16

Heh, yeah, it would be nice if module's .info and project pages on d.org were better linked, this approach probably makes the most sense.

#7

sun - November 4, 2009 - 23:49

So this is what it would look like.

AttachmentSize
admin_menu.devel-modules.7.patch 5.93 KB

#8

sun - November 4, 2009 - 23:50
Title:Turn admin_menu_developer_modules variable into a hook» Use .info file tags[] to categorize a module as developer module

Better title.

#9

dman - November 5, 2009 - 00:12

Hey, that could make sense! The project groupings in .info have always been a little ad-hoc.
Not quite sure what to use them for yet, but it looks like fun.

#10

Dave Reid - November 5, 2009 - 03:40

Yeah, this is a great approach. Doesn't require us to hard-code all modules, and maybe we can help get a jump start on improving the module page as well as integration with drupal.org project pages. I was thinking about also checking substr($module->name, -3) === '_ui' but that might be a little over the top.

A few modules (at least the ones I know about) we shouldn't need to include in the admin_menu_system_info_alter() since they already use the package 'Development':
coder
demo
devel
devel_node_access
devel_themer

Overall, ++++++++++100 to this and doing it sooner than later.

#11

designerbrent - November 5, 2009 - 05:27

This looks like a great addition. Thanks for making it so versatile.

#12

sun - November 5, 2009 - 12:53

+++ admin_menu.inc 4 Nov 2009 23:46:47 -0000
@@ -277,6 +268,28 @@ function admin_menu_theme_settings() {
+function admin_menu_developer_modules() {
+  $modules = array();
+  $result = db_query("SELECT name, info FROM {system} WHERE type = 'module'");
+  foreach ($result as $module) {
+    $info = unserialize($module->info);
+    // Add all modules in the "Development" package.
+    if (isset($info['package']) && $info['package'] == 'Development') {
+      $modules[$module->name] = $info['name'];
+    }
+    // Add all modules tagged with "development".
+    if (isset($info['tags']) && is_array($info['tags']) && in_array('development', $info['tags'])) {
+      $modules[$module->name] = $info['name'];
+    }
+  }
+  // Sort by human-readable module name.
+  asort($modules);
+  return $modules;
+}

I wonder whether we should consider to put a function like that as a last-minute attempt into Drupal 7 core.

Of course, without the wishy-washy package name checking. But very possible also supporting simple info variables, i.e. strings. And taking the thing to search for as argument.

That would allow us to retrieve, for example, a list of all hidden modules, or all required modules, or all modules in a certain package.

module_list_by_info($search = 'hidden', $parent = NULL);

Filter by tag:

module_list_by_info($search = 'development', $parent = 'tags');

Oh, and of course, also search for modules having a certain dependency:

module_list_by_info($search = 'views', $parent = 'dependencies');

I'm on crack. Are you, too?

Yes, I am. :)

#13

sun - November 5, 2009 - 23:19

#14

sun - November 7, 2009 - 16:49

I badly need some more traction/discussion/feedback/support in #624848: Allow to retrieve a list of modules defining a certain .info file property, so please comment over there to help flesh out the core version of this function.

 
 

Drupal is a registered trademark of Dries Buytaert.