Index: openacs-4/packages/related-items/lib/relate.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/related-items/lib/relate.adp,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/related-items/lib/relate.adp 15 Jun 2004 10:55:21 -0000 1.1
@@ -0,0 +1 @@
+
Index: openacs-4/packages/related-items/lib/relate.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/related-items/lib/relate.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/related-items/lib/relate.tcl 15 Jun 2004 10:55:21 -0000 1.1
@@ -0,0 +1,93 @@
+# /packages/cop-ui/www/related/relate.tcl
+ad_page_contract {
+ Relate object_id.
+ Requires registration.
+
+ @param object_one the target relate item
+ @param orderby "clipboard,desc"
+ @param admin_p
+
+ @author Jeff Davis davis@xarg.net
+ @creation-date 10/30/2003
+ @cvs-id $Id: relate.tcl,v 1.1 2004/06/15 10:55:21 jeffd Exp $
+} {}
+
+
+set elements {
+ type {
+ label {Type}
+ display_template "@relate.pretty_name@"
+ }
+ object_title {
+ label {Item}
+ }
+ clipboard {
+ label {Clipboard}
+ }
+ clipped {
+ label {Clipped on}
+ display_template "@relate.clipped;noquote@"
+ html {align right}
+ }
+}
+
+#lappend elements extra {
+# label {Debug}
+#}
+
+set bulk [list "Relate" relation-add]
+
+
+template::list::create \
+ -name relate \
+ -multirow relate \
+ -key object_id \
+ -elements $elements \
+ -orderby {
+ type {
+ orderby lower(t.pretty_name),x.clipped
+ }
+ object_title {
+ orderby lower(x.object_title),x.clipped
+ }
+ clipboard {
+ orderby lower(x.clipboard),x.clipped
+ }
+ clipped {
+ orderby x.clipped
+ }
+ } -filters {
+ object_one {}
+ } -bulk_actions $bulk -bulk_action_export_vars object_one
+
+set now [clock_to_ansi [clock seconds]]
+
+db_multirow -extend extra relate relate "
+ SELECT * FROM (
+ SELECT t.pretty_name,o.object_id, co.title as clipboard, coalesce(o.title,'? '|| o.object_type || o.object_id) as object_title, to_char(cm.clipped_on,'YYYY-MM-DD HH24:MI:SS') as clipped
+ FROM acs_objects o, clipboards c, acs_objects co, clipboard_object_map cm, acs_object_types t
+ WHERE c.owner_id = :user_id
+ and cm.clipboard_id = c.clipboard_id
+ and o.object_id = cm.object_id
+ and co.object_id = c.clipboard_id
+ and cm.object_id != :object_one
+ and t.object_type = o.object_type
+ UNION ALL
+ SELECT t.pretty_name, v.object_id, 'viewed', coalesce(o.title,'? ' || o.object_type || o.object_id) as object_title, to_char(v.last_viewed,'YYYY-MM-DD HH24:MI:SS')
+ FROM views v, acs_objects o, acs_object_types t
+ WHERE o.object_id = v.object_id
+ and v.viewer_id = :user_id
+ and v.object_id != :object_one
+ and t.object_type = o.object_type
+ ) x
+ WHERE not exists (
+ SELECT 1
+ FROM acs_rels
+ WHERE rel_type = 'content_rel'
+ and ( (object_id_one = :object_one and object_id_two = x.object_id)
+ or (object_id_one = x.object_id and object_id_two = :object_one)))
+ [template::list::orderby_clause -orderby -name "relate"]" {
+ set clipped [regsub -all { } [util::age_pretty -hours_limit 0 -mode_2_fmt "%X %a" -mode_3_fmt "%x" -timestamp_ansi $clipped -sysdate_ansi $now] {\ }]
+ }
+
+
Index: openacs-4/packages/related-items/lib/relation-add.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/related-items/lib/relation-add.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/related-items/lib/relation-add.tcl 15 Jun 2004 10:55:21 -0000 1.1
@@ -0,0 +1,37 @@
+# /packages/related-items/lib/related/relaion-add.tcl
+ad_page_contract {
+ Relate object_id to object_two (can be multiple)
+ Requires registration.
+
+ @author Jeff Davis davis@xarg.net
+ @creation-date 10/30/2003
+ @cvs-id $Id: relation-add.tcl,v 1.1 2004/06/15 10:55:21 jeffd Exp $
+} {
+ object_one:integer,notnull
+ object_id:multiple,integer,notnull
+ {return_url {}}
+}
+set user_id [auth::require_login]
+
+set vars [list \
+ [list object_id_one $object_one] \
+ [list creation_user $user_id] \
+ [list creation_ip [ad_conn peeraddr]] \
+ ]
+
+# don't insert a rel for the same object more than once.
+set seen($object_one) 1
+set count 0
+foreach object $object_id {
+ if {![info exists seen($object)]} {
+ package_exec_plsql -var_list [concat $vars [list [list object_id_two $object]]] content_rel new
+ set seen($object) 1
+ incr count
+ }
+}
+
+if {[string is space $return_url]} {
+ set return_url /o/$object_one
+}
+
+ad_returnredirect -message "Added $count related items" $return_url
Index: openacs-4/packages/related-items/lib/relation-delete.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/related-items/lib/relation-delete.tcl,v
diff -u -N
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/related-items/lib/relation-delete.tcl 15 Jun 2004 10:55:21 -0000 1.1
@@ -0,0 +1,23 @@
+# /packages/related-items/lib/related/relation-delete.tcl
+ad_page_contract {
+ Relate object_id to object_two (can be multiple)
+ Requires registration.
+
+ @author Jeff Davis davis@xarg.net
+ @creation-date 10/30/2003
+ @cvs-id $Id: relation-delete.tcl,v 1.1 2004/06/15 10:55:21 jeffd Exp $
+} {
+ rel_id:multiple,integer,notnull
+ {return_url {}}
+}
+set user_id [auth::require_login]
+
+foreach rel $rel_id {
+ package_exec_plsql -var_list [list [list rel_id $rel]] content_rel del
+}
+
+if {[string is space $return_url]} {
+ set return_url
+}
+
+ad_returnredirect -message "Deleted [llength $rel_id] related items" $return_url
Index: openacs-4/packages/related-items/sql/postgresql/relations-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/related-items/sql/postgresql/Attic/relations-create.sql,v
diff -u -N -r1.1 -r1.2
--- openacs-4/packages/related-items/sql/postgresql/relations-create.sql 14 Jun 2004 10:23:00 -0000 1.1
+++ openacs-4/packages/related-items/sql/postgresql/relations-create.sql 15 Jun 2004 10:55:21 -0000 1.2
@@ -57,7 +57,7 @@
select define_function_args('content_rel__new','rel_id,object_id_one,object_id_two,context_id,creation_user,creation_ip');
-create or replace function content_rel__delete(integer)
+create or replace function content_rel__del(integer)
returns integer as '
declare
rel_id alias for $1;
@@ -67,7 +67,7 @@
return 0;
end;' language 'plpgsql';
-select define_function_args('content_rel__delete','rel_id');
+select define_function_args('content_rel__del','rel_id');
create or replace function content_rel__title(integer)
Index: openacs-4/packages/related-items/www/relate.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/related-items/www/Attic/relate.adp,v
diff -u -N
--- openacs-4/packages/related-items/www/relate.adp 14 Jun 2004 10:23:00 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,5 +0,0 @@
-
- @title@
- @context@
-
-
Index: openacs-4/packages/related-items/www/relate.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/related-items/www/Attic/relate.tcl,v
diff -u -N
--- openacs-4/packages/related-items/www/relate.tcl 14 Jun 2004 10:23:00 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,108 +0,0 @@
-# /packages/cop-ui/www/related/relate.tcl
-ad_page_contract {
- Relate object_id.
- Requires registration.
-
- @author Jeff Davis davis@xarg.net
- @creation-date 10/30/2003
- @cvs-id $Id: relate.tcl,v 1.1 2004/06/14 10:23:00 jeffd Exp $
-} {
- object_one:integer,notnull
- {orderby "clipboard,desc"}
-}
-
-set user_id [auth::require_login]
-
-set admin_p [permission::permission_p -object_id [ad_conn package_id] -privilege admin]
-
-set title "Relate"
-if {![empty_string_p $object_one]} {
- set object_name [db_string object_name {select acs_object__name(:object_one);} -default {}]
- if {![empty_string_p object_name]} {
- append title " to $object_name"
- } else {
- append title " to object $object_on"
- }
-}
-
-
-set context [list [list ./ relate] {relate object}]
-
-set elements {
- type {
- label {Type}
- display_template "@relate.pretty_name@"
- }
- object_title {
- label {Item}
- }
- clipboard {
- label {Clipboard}
- }
- clipped {
- label {Clipped on}
- display_template "@relate.clipped;noquote@"
- html {align right}
- }
-}
-
-#lappend elements extra {
-# label {Debug}
-#}
-
-set bulk [list "Relate" relation-add]
-
-
-template::list::create \
- -name relate \
- -multirow relate \
- -key object_id \
- -elements $elements \
- -orderby {
- type {
- orderby lower(t.pretty_name),x.clipped
- }
- object_title {
- orderby lower(x.object_title),x.clipped
- }
- clipboard {
- orderby lower(x.clipboard),x.clipped
- }
- clipped {
- orderby x.clipped
- }
- } -filters {
- object_one {}
- } -bulk_actions $bulk -bulk_action_export_vars object_one
-
-set now [clock_to_ansi [clock seconds]]
-
-db_multirow -extend extra relate relate "
- SELECT * FROM (
- SELECT t.pretty_name,o.object_id, co.title as clipboard, coalesce(o.title,'? '|| o.object_type || o.object_id) as object_title, to_char(cm.clipped_on,'YYYY-MM-DD HH24:MI:SS') as clipped
- FROM acs_objects o, cop_clipboards c, acs_objects co, cop_clipboard_object_map cm, acs_object_types t
- WHERE c.owner_id = :user_id
- and cm.clipboard_id = c.clipboard_id
- and o.object_id = cm.object_id
- and co.object_id = c.clipboard_id
- and cm.object_id != :object_one
- and t.object_type = o.object_type
- UNION ALL
- SELECT t.pretty_name, v.object_id, 'viewed', coalesce(o.title,'? ' || o.object_type || o.object_id) as object_title, to_char(v.last_viewed,'YYYY-MM-DD HH24:MI:SS')
- FROM cop_object_views v, acs_objects o, acs_object_types t
- WHERE o.object_id = v.object_id
- and v.viewer_id = :user_id
- and v.object_id != :object_one
- and t.object_type = o.object_type
- ) x
- WHERE not exists (
- SELECT 1
- FROM acs_rels
- WHERE rel_type = 'cop_rel'
- and ( (object_id_one = :object_one and object_id_two = x.object_id)
- or (object_id_one = x.object_id and object_id_two = :object_one)))
- [template::list::orderby_clause -orderby -name "relate"]" {
- set clipped [regsub -all { } [util::age_pretty -hours_limit 0 -mode_2_fmt "%X %a" -mode_3_fmt "%x" -timestamp_ansi $clipped -sysdate_ansi $now] {\ }]
- }
-
-
Index: openacs-4/packages/related-items/www/relation-add.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/related-items/www/Attic/relation-add.tcl,v
diff -u -N
--- openacs-4/packages/related-items/www/relation-add.tcl 14 Jun 2004 10:23:00 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,27 +0,0 @@
-# /packages/cop-ui/www/related/relate.tcl
-ad_page_contract {
- Relate object_id to object_two (can be multiple)
- Requires registration.
-
- @author Jeff Davis davis@xarg.net
- @creation-date 10/30/2003
- @cvs-id $Id: relation-add.tcl,v 1.1 2004/06/14 10:23:00 jeffd Exp $
-} {
- object_one:integer,notnull
- object_id:multiple,integer,notnull
-}
-
-set user_id [auth::require_login]
-
-set vars [list \
- [list object_id_one $object_one] \
- [list creation_user $user_id] \
- [list creation_ip [ad_conn peeraddr]] \
- ]
-
-foreach object $object_id {
- ns_log DEBUG "JCD: relating $object to $object_one ($object_id)"
- package_exec_plsql -var_list [concat $vars [list [list object_id_two $object]]] cop_rel new
-}
-
-ad_returnredirect -message "Added [llength $object_id] related items" relate?object_one=$object_one