From 0985f868e298a4f60bb8299dcc2fe8effffdb326 Mon Sep 17 00:00:00 2001
From: Helior Colorado <me@helior.info>
Date: Wed, 17 Oct 2012 00:08:27 -0700
Subject: [PATCH] Added support for searching sub-profiles.

---
 libraries.module | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/libraries.module b/libraries.module
index 18c0dd8..89dca50 100644
--- a/libraries.module
+++ b/libraries.module
@@ -52,7 +52,7 @@ function libraries_get_path($name, $base_path = FALSE) {
  * Returns an array of library directories.
  *
  * Returns an array of library directories from the all-sites directory
- * (i.e. sites/all/libraries/), the profiles directory, and site-specific
+ * (i.e. sites/all/libraries/), the profiles directories, and site-specific
  * directory (i.e. sites/somesite/libraries/). The returned array will be keyed
  * by the library name. Site-specific libraries are prioritized over libraries
  * in the default directories. That is, if a library with the same name appears
@@ -66,7 +66,6 @@ function libraries_get_path($name, $base_path = FALSE) {
  */
 function libraries_get_libraries() {
   $searchdir = array();
-  $profile = drupal_get_path('profile', drupal_get_profile());
   $config = conf_path();
 
   // Similar to 'modules' and 'themes' directories in the root directory,
@@ -77,7 +76,9 @@ function libraries_get_libraries() {
   // Similar to 'modules' and 'themes' directories inside an installation
   // profile, installation profiles may want to place libraries into a
   // 'libraries' directory.
-  $searchdir[] = "$profile/libraries";
+  foreach (drupal_get_profiles(drupal_get_profile()) as $profile) {
+    $searchdir[] = drupal_get_path('profile', $profile) . '/libraries';
+  }
 
   // Always search sites/all/libraries.
   $searchdir[] = 'sites/all/libraries';
@@ -119,13 +120,16 @@ function libraries_get_libraries() {
  *   the files.
  */
 function libraries_scan_info_files() {
-  $profile = drupal_get_path('profile', drupal_get_profile());
   $config = conf_path();
 
   // Build a list of directories.
   $directories = module_invoke_all('libraries_info_file_paths');
   $directories[] = 'libraries';
-  $directories[] = "$profile/libraries";
+
+  foreach (drupal_get_profiles(drupal_get_profile()) as $profile) {
+    $directories[] = drupal_get_path('profile', $profile) . '/libraries';
+  }
+
   $directories[] = 'sites/all/libraries';
   $directories[] = "$config/libraries";
 
-- 
1.7.12

