Index: openacs-4/packages/edit-this-page/sql/postgresql/upgrade/upgrade-1.1d-1.2b.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/edit-this-page/sql/postgresql/upgrade/Attic/upgrade-1.1d-1.2b.sql,v
diff -u -r1.1.2.3 -r1.1.2.4
--- openacs-4/packages/edit-this-page/sql/postgresql/upgrade/upgrade-1.1d-1.2b.sql	30 Jan 2003 05:16:47 -0000	1.1.2.3
+++ openacs-4/packages/edit-this-page/sql/postgresql/upgrade/upgrade-1.1d-1.2b.sql	30 Jan 2003 11:49:24 -0000	1.1.2.4
@@ -120,4 +120,57 @@
 
 end;' language 'plpgsql';
 
+create or replace function etp__get_title(integer, varchar)
+returns varchar as '
+declare
+  p_item_id alias for $1;
+  p_revision_title alias for $2;
+  v_item_id integer;
+  v_title varchar(400);
+  v_object_type varchar;
+begin
+  if p_revision_title is not null then
+    return p_revision_title;
+  end if;
+
+  select object_type from acs_objects into v_object_type
+   where object_id = p_item_id;
+
+  if v_object_type = ''content_folder'' then
+    select r.title 
+      into v_title
+      from cr_items i, cr_revisions r
+     where i.parent_id = p_item_id
+       and i.name = ''index''
+       and i.live_revision = r.revision_id;
+    return v_title;    
+  end if;
+
+  if v_object_type = ''content_extlink'' then
+    select label into v_title
+      from cr_extlinks
+     where extlink_id = p_item_id;
+    return v_title;
+  end if;
+
+  if v_object_type = ''content_symlink'' then
+    select target_id into v_item_id
+      from cr_symlinks
+     where symlink_id = p_item_id;
+    return etp__get_title(v_item_id, null);
+  end if;
+
+  if v_object_type = ''content_item'' then
+    select r.title into v_title
+      from cr_items i, cr_revisions r
+     where i.item_id = v_item_id
+       and i.live_revision = r.revision_id;
+    return v_title;
+  end if;  
+   
+  return null;
+
+end;
+' language 'plpgsql';
+
 /i ../edit-this-page-sc-create.sql
\ No newline at end of file
