commit 6089b33a753e7b3d548686ab36e99843cfea0283
Author: Marc Dequènes (Duck) <Duck@DuckCorp.org>
Date:   Fri Jul 24 22:03:13 2009 +0200

    [evol] added list of available objects and aspects of objects, and s/ou/unit/ object

diff --git a/bin/shadowwalker b/bin/shadowwalker
index cebcda8..89fdbe2 100755
--- a/bin/shadowwalker
+++ b/bin/shadowwalker
@@ -75,20 +75,46 @@ ldapctl.load_relations
 cmd = CmdParse::Command.new('list', false)
 cmd.short_desc = "list objects"
 cmd.set_execution_block do |args|
-  if args.size != 1
+  if args.size < 1
     STDERR.puts "syntax error: no object name given"
     exit 1
   end
 
   obj_hdl = args.shift.singularize
-  obj_klass = ldapctl.find_klass(obj_hdl)
-  if obj_klass.nil?
-    STDERR.puts "No such object '#{obj_hdl}'."
-    exit 2
-  end
+  case obj_hdl
+  when ':object'
+    puts "=== List of LDAP objects ==="
+    ldapctl.objects.each do |obj_name|
+      puts "  - #{obj_name}"
+    end
+  when ':aspect'
+    if args.empty?
+      STDERR.puts "syntax error: no sub-object name given"
+      exit 1
+    end
+
+    subobj_hdl = args.shift.singularize
+    obj_klass = ldapctl.find_klass(subobj_hdl)
+    if obj_klass.nil?
+      STDERR.puts "No such object '#{obj_hdl}'."
+      exit 2
+    end
+
+    subobj_human_name = Translator.translate_object_name(subobj_hdl)
+    puts "=== List of LDAP aspects of #{subobj_human_name.pluralize} ==="
+    obj_klass.possible_aspects.each do |subobj_name|
+      puts "  - #{subobj_name}"
+    end
+  else
+    obj_klass = ldapctl.find_klass(obj_hdl)
+    if obj_klass.nil?
+      STDERR.puts "No such object '#{obj_hdl}'."
+      exit 2
+    end
 
-  obj_human_name = Translator.translate_object_name(obj_hdl)
-  Display.display_item_list("List of " + obj_human_name.pluralize, obj_klass.find(:all))
+    obj_human_name = Translator.translate_object_name(obj_hdl)
+    Display.display_item_list("List of #{obj_human_name.pluralize}", obj_klass.find(:all))
+  end
 end
 cmdparser.add_command(cmd)
 
diff --git a/conf/ldap_shadows/test.conf b/conf/ldap_shadows/test.conf
index 941b371..21967ac 100644
--- a/conf/ldap_shadows/test.conf
+++ b/conf/ldap_shadows/test.conf
@@ -1,7 +1,7 @@
 ---
 presentation:
   hidden_attributes: ['objectClass', 'userPassword']
-  tree_objects: ['ou', 'entity']
+  tree_objects: ['unit', 'entity']
 objects:
   bot:
     mapping:
@@ -80,7 +80,7 @@ objects:
         object: entity
         foreign_key: founder
         primary_key: dn
-  ou:
+  unit:
     mapping:
       dn_attribute: ou
       prefix: ''
diff --git a/data/ldap_shadows/en.yml b/data/ldap_shadows/en.yml
index b10eba0..4521b30 100644
--- a/data/ldap_shadows/en.yml
+++ b/data/ldap_shadows/en.yml
@@ -1,13 +1,14 @@
 ---
 en:
   objects:
-    individual: "Individual"
     bot: "Bot"
-    group: "Group"
+    domain: "Domain"
     entity: "Entity"
+    group: "Group"
+    individual: "Individual"
     secondary_account: "Secondary Account"
     systemAccount: "System Account"
-    domain: "Domain"
+    unit: "Unit"
   attribute_types:
     allowGlobalDirectory: "Disclose Own Contact Information in GLobal Directory"
     cn: "Full Name"
@@ -59,10 +60,10 @@ en:
     foundersIndividuals: "Founder(s) Individual(s)"
     foundersEntities: "Founder(s) Entity(ies)"
   aspects:
-    primary: "Primary Account"
-    ftp: "FTP Account"
-    web: "Web Account"
-    shell: "Shell Account"
     fs: "FileSystem Account"
-    mail: "eMail Account"
+    ftp: "FTP Account"
     jabber: "Jabber Account"
+    mail: "eMail Account"
+    primary: "Primary Account"
+    shell: "Shell Account"
+    web: "Web Account"
diff --git a/lib/ldap_shadows/controller.rb b/lib/ldap_shadows/controller.rb
index 07006fe..0235753 100755
--- a/lib/ldap_shadows/controller.rb
+++ b/lib/ldap_shadows/controller.rb
@@ -115,6 +115,10 @@ module LdapShadows
         klass.relations_info = obj_relations_info
       end
     end
+
+    def objects
+      @object_definitions.keys.collect{|key| key.to_s }.sort
+    end
   end
 
   # default location for mapped objects
diff --git a/lib/ldap_shadows/object.rb b/lib/ldap_shadows/object.rb
index ed522dc..210e4c3 100755
--- a/lib/ldap_shadows/object.rb
+++ b/lib/ldap_shadows/object.rb
@@ -129,6 +129,11 @@ module LdapShadows
       rel_list & possible_relations
     end
 
+    def self.possible_aspects
+      return [] unless self.presentation[:allowed_aspects]
+      self.presentation[:allowed_aspects].collect{|key| key.to_s }.sort
+    end
+
     def aspects
       present_aspects = []
       (self.class.presentation[:allowed_aspects] || []).each do |aspect|
