commit 2cb9783056d36e1b4862e5af7fb4cbd019cf2485
Author: Marc Dequènes (Duck) <Duck@DuckCorp.org>
Date:   Fri Apr 9 01:42:28 2010 +0200

    [evol] use a plugins-pecific include dir to share functions among plugins easily (closes #36)

diff --git a/conf/ldap_shadows/shadows/MilkyPond/plugins/aspects/primary_account.rb b/conf/ldap_shadows/shadows/MilkyPond/plugins/aspects/primary_account.rb
index 32787c5..74998fb 100644
--- a/conf/ldap_shadows/shadows/MilkyPond/plugins/aspects/primary_account.rb
+++ b/conf/ldap_shadows/shadows/MilkyPond/plugins/aspects/primary_account.rb
@@ -1,4 +1,6 @@
 
+require 'shared_attributes'
+
 def self.hook_before_create(item)
   hook_common(item)
 end
@@ -8,14 +10,6 @@ def self.hook_before_modify(item)
 end
 
 def self.hook_common(item)
-  if item.attribute_present?('allowedServices')
-    user_services = ActiveLdap::Base.find(:all, :scope => :sub, :filter => "(objectClass=userService)", :attributes => ['cn'])
-    srv_names =  user_services.collect {|srv| srv.cn }
-
-    invalid_srv_names = item.allowedServices(true) - (item.allowedServices(true) & srv_names)
-    unless invalid_srv_names.empty?
-      raise PreProcessingError, "Invalid User Service(s) name(s): " + invalid_srv_names.join(", ")
-    end
-  end
+  SharedAttr.check_common_attributes(item)
 end
 
diff --git a/conf/ldap_shadows/shadows/MilkyPond/plugins/includes/shared_attributes.rb b/conf/ldap_shadows/shadows/MilkyPond/plugins/includes/shared_attributes.rb
new file mode 100644
index 0000000..0c7922d
--- /dev/null
+++ b/conf/ldap_shadows/shadows/MilkyPond/plugins/includes/shared_attributes.rb
@@ -0,0 +1,15 @@
+module SharedAttr
+  module_function
+
+  def check_common_attributes(item)
+    if item.attribute_present?('allowedServices')
+      user_services = ActiveLdap::Base.find(:all, :scope => :sub, :filter => "(objectClass=userService)", :attributes => ['cn'])
+      srv_names =  user_services.collect {|srv| srv.cn }
+
+      invalid_srv_names = item.allowedServices(true) - (item.allowedServices(true) & srv_names)
+      unless invalid_srv_names.empty?
+        raise PreProcessingError, "Invalid User Service(s) name(s): " + invalid_srv_names.join(", ")
+      end
+    end
+  end
+end
diff --git a/conf/ldap_shadows/shadows/MilkyPond/plugins/objects/secondary_account.rb b/conf/ldap_shadows/shadows/MilkyPond/plugins/objects/secondary_account.rb
index 32787c5..74998fb 100644
--- a/conf/ldap_shadows/shadows/MilkyPond/plugins/objects/secondary_account.rb
+++ b/conf/ldap_shadows/shadows/MilkyPond/plugins/objects/secondary_account.rb
@@ -1,4 +1,6 @@
 
+require 'shared_attributes'
+
 def self.hook_before_create(item)
   hook_common(item)
 end
@@ -8,14 +10,6 @@ def self.hook_before_modify(item)
 end
 
 def self.hook_common(item)
-  if item.attribute_present?('allowedServices')
-    user_services = ActiveLdap::Base.find(:all, :scope => :sub, :filter => "(objectClass=userService)", :attributes => ['cn'])
-    srv_names =  user_services.collect {|srv| srv.cn }
-
-    invalid_srv_names = item.allowedServices(true) - (item.allowedServices(true) & srv_names)
-    unless invalid_srv_names.empty?
-      raise PreProcessingError, "Invalid User Service(s) name(s): " + invalid_srv_names.join(", ")
-    end
-  end
+  SharedAttr.check_common_attributes(item)
 end
 
diff --git a/conf/ldap_shadows/shadows/MilkyPond/plugins/objects/system_account.rb b/conf/ldap_shadows/shadows/MilkyPond/plugins/objects/system_account.rb
index 32787c5..74998fb 100644
--- a/conf/ldap_shadows/shadows/MilkyPond/plugins/objects/system_account.rb
+++ b/conf/ldap_shadows/shadows/MilkyPond/plugins/objects/system_account.rb
@@ -1,4 +1,6 @@
 
+require 'shared_attributes'
+
 def self.hook_before_create(item)
   hook_common(item)
 end
@@ -8,14 +10,6 @@ def self.hook_before_modify(item)
 end
 
 def self.hook_common(item)
-  if item.attribute_present?('allowedServices')
-    user_services = ActiveLdap::Base.find(:all, :scope => :sub, :filter => "(objectClass=userService)", :attributes => ['cn'])
-    srv_names =  user_services.collect {|srv| srv.cn }
-
-    invalid_srv_names = item.allowedServices(true) - (item.allowedServices(true) & srv_names)
-    unless invalid_srv_names.empty?
-      raise PreProcessingError, "Invalid User Service(s) name(s): " + invalid_srv_names.join(", ")
-    end
-  end
+  SharedAttr.check_common_attributes(item)
 end
 
diff --git a/lib/ldap_shadows/config.rb b/lib/ldap_shadows/config.rb
index dba2301..7a1690b 100644
--- a/lib/ldap_shadows/config.rb
+++ b/lib/ldap_shadows/config.rb
@@ -90,6 +90,9 @@ module LdapShadows
       }
       shadow.set_config(config)
 
+      include_path = File.join(shadow_config_path, "plugins", "includes")
+      $:.unshift(include_path) if File.directory?(include_path)
+
       load_element_config(shadow_config_path, 'aspects') do |c_name, c_config|
         shadow.add_aspect(c_name, c_config)
       end
