Index: openacs-4/packages/dotlrn-fs/www/all-objects-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/dotlrn-fs/www/all-objects-postgresql.xql,v
diff -u -r1.2 -r1.3
--- openacs-4/packages/dotlrn-fs/www/all-objects-postgresql.xql	27 Oct 2014 16:41:20 -0000	1.2
+++ openacs-4/packages/dotlrn-fs/www/all-objects-postgresql.xql	15 May 2015 13:34:31 -0000	1.3
@@ -9,20 +9,33 @@
            fs_folders.name as folder_name
     from fs_objects,
          fs_folders
-    where fs_objects.object_id in (select acs_objects.object_id
-                                   from acs_objects
-                                   where acs_objects.tree_sortkey between tree_left(acs_objects.tree_sortkey) and tree_right(acs_objects.tree_sortkey)
-                                   and acs_objects.context_id in (select site_node_object_mappings.object_id
-                                                                         from site_node_object_mappings,
-                                                                              site_nodes,
-                                                                              fs_root_folders
-                                                                         where site_node_object_mappings.node_id = site_nodes.node_id
-                                                                         and site_node_object_mappings.object_id = fs_root_folders.folder_id
-                                                                         and site_nodes.parent_id in (select sn.node_id
-                                                                                                      from site_nodes sn,
-                                                                                                           apm_packages ap
-                                                                                                      where sn.object_id = ap.package_id
-                                                                                                      and ap.package_key = :dotlrn_package_key)))
+    where fs_objects.object_id in (
+    	  WITH RECURSIVE fs_objects(object_id) as (
+    	       select acs_objects.object_id
+    	       from acs_objects
+    	       where acs_objects.context_id in (
+    	       	     select site_node_object_mappings.object_id
+    		     from site_node_object_mappings,
+    		     site_nodes,
+    		     fs_root_folders
+    		     where site_node_object_mappings.node_id = site_nodes.node_id
+    		     and site_node_object_mappings.object_id = fs_root_folders.folder_id
+    		     and site_nodes.parent_id in (
+    		     	 select sn.node_id
+    			 from site_nodes sn,
+    			 apm_packages ap
+    			 where sn.object_id = ap.package_id
+    			 and ap.package_key = 'dotlrn'
+    		    	 )
+    		    )
+    
+	   UNION ALL 
+
+	   select ao.object_id 
+    	   from acs_objects ao join fs_objects fo on (fo.object_id = ao.context_id)
+	   )
+	   select object_id from fs_objects
+	   )
     and fs_objects.parent_id = fs_folders.folder_id
     and fs_objects.type <> 'folder'
     and fs_objects.last_modified >= (now() - (:n_past_days || ' days')::interval)