Index: openacs-4/contrib/packages/cop-base/lib/cop-footer.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/lib/cop-footer.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/lib/cop-footer.tcl 28 Mar 2004 21:17:13 -0000 1.1
@@ -0,0 +1,73 @@
+# generic stuff we need
+set url [cop::util::url -subsite_id [ad_conn subsite_id]]
+set subsite [ad_conn subsite_id]
+set user_id [ad_conn user_id]
+set cur_pkg [ad_conn package_id]
+set ratingicons [cop::rating::icon_base]
+
+db_1row obj_title {select pretty_name as tname, pretty_plural as tname_s, title as obj_title, package_id as obj_pkg, acs_object__name(object_id) as acs_name from acs_objects o, acs_object_types t where object_id = :displayed_object_id and t.object_type = o.object_type}
+if {[empty_string_p $obj_title]} {
+ set obj_title EMPTY
+}
+
+if {[empty_string_p $acs_name]} {
+ set acs_name EMPTY
+}
+
+# get the clipboard info
+cop::clipboard::clipboards -create_new -force_default [ad_conn user_id] clipboards
+cop::clipboard::clipped $displayed_object_id [ad_conn user_id] clipped
+
+
+# record object view and get current count.
+db_string record_view "select cop_object_record_view(:displayed_object_id, :user_id)" -default 0
+if {![db_0or1row views "select views, unique_views from cop_object_view_agg where object_id = :displayed_object_id"]} {
+ set views missing
+ set unique_views missing
+}
+
+
+# Stuff for ratings.
+set rate_form [cop::rating::widget -object_one $displayed_object_id]
+set current_rating [cop::rating::get -object_one $displayed_object_id -user_id $user_id]
+array set ratings [cop::rating::aggregate::get -object_one $displayed_object_id]
+if {[info exists ratings(ratings)]} {
+ set ratings(stars) [format %.1f [expr round($ratings(rating_sum)*2.0/$ratings(ratings))/2.0]]
+} else {
+ set ratings(ratings) 0
+}
+if {![empty_string_p $current_rating]} {
+ set stars [format %.1f $current_rating ]
+}
+
+
+
+
+# stuff for comments
+# todo: suppress for things that should not be commentable.
+set comment_link {}
+append comment_link [general_comments_get_comments -print_content_p 1 $displayed_object_id [ad_return_url]]
+append comment_link [general_comments_create_link -object_name "Name for $displayed_object_id" -link_attributes {class="button"} $displayed_object_id [ad_return_url] ]
+
+
+# Stuff for related items
+cop::relation::get_related -object_id $displayed_object_id -datasource related
+
+
+# Category mapping stuff
+# add category form
+ad_form -action $url/categories/map -method GET -name catass -form {
+ {object_id:integer(hidden)
+ {value $displayed_object_id}
+ }
+ {container_id:integer(hidden)
+ {value {[ad_conn subsite_id]}}
+ }
+}
+category::ad_form::add_widgets -container_object_id [ad_conn subsite_id] -form_name catass
+
+# mapped categories:
+set catass_list "[category::get_mapped_categories $displayed_object_id] : [category::list::get_pretty_list [category::get_mapped_categories $displayed_object_id]]"
+
+# dummy for debug
+set foo {}
Index: openacs-4/contrib/packages/cop-base/sql/postgresql/clipboard-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/sql/postgresql/Attic/clipboard-create.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/sql/postgresql/clipboard-create.sql 28 Mar 2004 21:17:14 -0000 1.1
@@ -0,0 +1,62 @@
+-- Simple object clipboard datamodel
+--
+-- Copyright (C) 2003 Jeff Davis
+-- @author Jeff Davis davis@xarg.net
+-- @creation-date 10/22/2003
+--
+-- @cvs-id $Id: clipboard-create.sql,v 1.1 2004/03/28 21:17:14 jeffd Exp $
+--
+-- This is free software distributed under the terms of the GNU Public
+-- License. Full text of the license is available from the GNU Project:
+-- http://www.fsf.org/copyleft/gpl.html
+
+create table cop_clipboards (
+ clipboard_id integer
+ constraint cop_clipboards_clipbd_id_fk
+ references acs_objects(object_id)
+ constraint cop_clipboards_pk
+ primary key,
+ owner_id integer
+ constraint cop_clipboards_owner_id_fk
+ references parties(party_id) on delete cascade
+ constraint cop_clipboards_owner_id_nn
+ not null
+);
+
+comment on table cop_clipboards is '
+ Table for saving a collection of object_ids. created as an acs_object
+ so it can be permissioned and categorized.
+';
+
+create table cop_clipboard_object_map (
+ clipboard_id integer
+ constraint cop_clipboards_fk
+ references cop_clipboards(clipboard_id) on delete cascade,
+ object_id integer
+ constraint cop_clipboard_acs_objects_fk
+ references acs_objects(object_id) on delete cascade,
+i clipped_on timestamptz,
+ constraint cop_clipboard_object_map_pk
+ primary key (clipboard_id, object_id)
+);
+
+comment on table cop_clipboard_object_map is '
+ Map stores which objects have been saved to a given clipboard.
+';
+
+
+select acs_object_type__create_type(
+ 'cop_clipboard',
+ 'COP Clipboard',
+ 'COP Clipboards',
+ 'acs_object',
+ 'cop_clipboards',
+ 'clipboard_id',
+ 'cop_clipboard',
+ 'f',
+ 'cop_clipboard__title',
+ null
+);
+
+
+
Index: openacs-4/contrib/packages/cop-base/sql/postgresql/clipboard-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/sql/postgresql/Attic/clipboard-drop.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/sql/postgresql/clipboard-drop.sql 28 Mar 2004 21:17:14 -0000 1.1
@@ -0,0 +1,38 @@
+-- Simple object clipboard datamodel
+--
+-- Copyright (C) 2003 Jeff Davis
+-- @author Jeff Davis davis@xarg.net
+-- @creation-date 10/22/2003
+--
+-- @cvs-id $Id: clipboard-drop.sql,v 1.1 2004/03/28 21:17:14 jeffd Exp $
+--
+-- This is free software distributed under the terms of the GNU Public
+-- License. Full text of the license is available from the GNU Project:
+-- http://www.fsf.org/copyleft/gpl.html
+
+create or replace function tmp_cop_clip_delete ()
+returns integer as '
+declare
+ coll_rec RECORD;
+begin
+ for coll_rec in select object_id
+ from acs_objects
+ where object_type = ''cop_clipboard''
+ loop
+ PERFORM acs_object__delete (coll_rec.object_id);
+ end loop;
+
+ return 1;
+end; ' language 'plpgsql';
+
+select tmp_cop_clip_delete ();
+drop function tmp_cop_clip_delete ();
+
+select acs_object_type__drop_type('cop_clipboard', 'f');
+drop table cop_clipboard_object_map;
+drop table cop_clipboards;
+
+drop function cop_clipboard__new (integer,integer,varchar,integer,timestamptz,integer,varchar,integer);
+drop function cop_clipboard__title (integer);
+drop function cop_clipboard__delete (integer);
+
Index: openacs-4/contrib/packages/cop-base/sql/postgresql/clipboard-procs.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/sql/postgresql/Attic/clipboard-procs.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/sql/postgresql/clipboard-procs.sql 28 Mar 2004 21:17:14 -0000 1.1
@@ -0,0 +1,84 @@
+-- Simple object clipboard plpgsql procedures
+--
+-- Copyright (C) 2003 Jeff Davis
+-- @author Jeff Davis davis@xarg.net
+-- @creation-date 10/22/2003
+--
+-- @cvs-id $Id: clipboard-procs.sql,v 1.1 2004/03/28 21:17:14 jeffd Exp $
+--
+-- This is free software distributed under the terms of the GNU Public
+-- License. Full text of the license is available from the GNU Project:
+-- http://www.fsf.org/copyleft/gpl.html
+
+create or replace function cop_clipboard__new (integer,integer,varchar,integer,timestamptz,integer,varchar,integer)
+returns integer as '
+declare
+ p_clipboard_id alias for $1; -- default null
+ p_owner_id alias for $2; -- default null
+ p_title alias for $3;
+ p_package_id alias for $4;
+ p_creation_date alias for $5; -- default now()
+ p_creation_user alias for $6; -- default null
+ p_creation_ip alias for $7; -- default null
+ p_context_id alias for $8; -- default null
+ v_clipboard_id cop_clipboards.clipboard_id%TYPE;
+begin
+ v_clipboard_id := acs_object__new (
+ p_clipboard_id,
+ ''cop_clipboard'',
+ p_creation_date,
+ p_creation_user,
+ p_creation_ip,
+ p_context_id,
+ ''t'',
+ p_title,
+ p_package_id);
+
+ insert into cop_clipboards (clipboard_id, owner_id)
+ values (v_clipboard_id, p_owner_id);
+
+ PERFORM acs_permission__grant_permission(
+ v_clipboard_id,
+ p_owner_id,
+ ''admin'');
+
+ return v_clipboard_id;
+
+end;' language 'plpgsql';
+
+create or replace function cop_clipboard__delete (integer)
+returns integer as '
+declare
+ p_clipboard_id alias for $1;
+begin
+ if exists (select 1 from acs_objects where object_id = p_clipboard_id and object_type = ''cop_clipboard'') then
+ delete from acs_permissions
+ where object_id = p_clipboard_id;
+
+ delete from cop_clipboards
+ where clipboard_id = p_clipboard_id;
+
+ PERFORM acs_object__delete(p_clipboard_id);
+
+ return 0;
+ else
+ raise NOTICE ''cop_clipboard__delete object_id % does not exist or is not a cop_clipboard'',p_clipboard_id;
+ return 0;
+ end if;
+end;' language 'plpgsql';
+
+
+create or replace function cop_clipboard__title (integer)
+returns varchar as '
+declare
+ p_clipboard_id alias for $1;
+ v_title varchar;
+begin
+ SELECT title into v_title
+ FROM acs_objects
+ WHERE object_id = p_clipboard_id
+ and object_type = ''cop_clipboard'';
+
+ return v_title;
+end;
+' language 'plpgsql';
Index: openacs-4/contrib/packages/cop-base/sql/postgresql/cop-base-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/sql/postgresql/cop-base-create.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/sql/postgresql/cop-base-create.sql 28 Mar 2004 21:17:14 -0000 1.1
@@ -0,0 +1,24 @@
+-- /packages/cop-base/sql/postgresql/cop-base-create.sql
+
+-- Community-Of-Practice datamodel
+--
+-- Copyright (C) 2003 Jeff Davis
+-- @author Jeff Davis
+-- @creation-date 10/22/2003
+--
+-- @cvs-id $Id: cop-base-create.sql,v 1.1 2004/03/28 21:17:14 jeffd Exp $
+--
+-- This is free software distributed under the terms of the GNU Public
+-- License. Full text of the license is available from the GNU Project:
+-- http://www.fsf.org/copyleft/gpl.html
+
+\i clipboard-create.sql
+\i clipboard-procs.sql
+
+\i views-create.sql
+\i views-triggers.sql
+\i views-procs.sql
+
+\i ratings-create.sql
+\i ratings-procs.sql
+\i ratings-data.sql
Index: openacs-4/contrib/packages/cop-base/sql/postgresql/cop-base-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/sql/postgresql/cop-base-drop.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/sql/postgresql/cop-base-drop.sql 28 Mar 2004 21:17:14 -0000 1.1
@@ -0,0 +1,19 @@
+-- /packages/cop-base/sql/postgresql/cop-base-drop.sql
+
+-- Community-Of-Practice DROP full datamodel.
+--
+-- Copyright (C) 2003 Jeff Davis
+-- @author Jeff Davis
+-- @creation-date 10/22/2003
+--
+-- @cvs-id $Id: cop-base-drop.sql,v 1.1 2004/03/28 21:17:14 jeffd Exp $
+--
+-- This is free software distributed under the terms of the GNU Public
+-- License. Full text of the license is available from the GNU Project:
+-- http://www.fsf.org/copyleft/gpl.html
+
+\i clipboard-drop.sql
+
+\i views-drop.sql
+
+\i ratings-drop.sql
Index: openacs-4/contrib/packages/cop-base/sql/postgresql/ratings-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/sql/postgresql/Attic/ratings-create.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/sql/postgresql/ratings-create.sql 28 Mar 2004 21:17:14 -0000 1.1
@@ -0,0 +1,134 @@
+-- Simple multidimensional rating package.
+--
+-- Copyright (C) 2003 Jeff Davis
+-- @author Jeff Davis
+-- @creation-date 10/22/2003
+--
+-- @cvs-id $Id: ratings-create.sql,v 1.1 2004/03/28 21:17:14 jeffd Exp $
+--
+-- This is free software distributed under the terms of the GNU Public
+-- License. Full text of the license is available from the GNU Project:
+-- http://www.fsf.org/copyleft/gpl.html
+
+create table cop_rating_dimensions (
+ dimension_id integer
+ constraint cop_rating_dims_object_id_fk
+ references acs_objects(object_id)
+ constraint cop_rating_dimensions_pk
+ primary key,
+ dimension_key varchar(100)
+ constraint cop_rating_dims_dim_key_nn
+ not null,
+ description text,
+ object_two_p char(1) default 't'
+ constraint cop_rating_dimensions_obj2_p_ck
+ check (object_two_p in ('t','f')),
+ range_low integer default 1,
+ range_high integer default 5,
+ label_low text default 'worst',
+ label_high text default 'best'
+);
+
+comment on table cop_rating_dimensions is '
+ The dimensions along which an object can be rated.
+ Typically this is with respect to a category in table cop_ratings.
+';
+
+comment on column cop_rating_dimensions.object_two_p is '
+ Is an object_two required when rating along this dimension.
+';
+
+create table cop_ratings (
+ rating_id integer
+ constraint cop_ratings_object_id_fk
+ references acs_objects(object_id)
+ constraint cop_ratings_rating_id_pk
+ primary key,
+ dimension_id integer
+ constraint cop_ratings_dimension_id_fk
+ references cop_rating_dimensions(dimension_id) on delete cascade,
+ object_one integer
+ constraint cop_ratings_object_one_fk
+ references acs_objects(object_id) on delete cascade
+ constraint cop_ratings_object_one_nn
+ not null,
+ object_two integer
+ constraint cop_ratings_object_two_fk
+ references acs_objects(object_id) on delete cascade
+ constraint cop_ratings_object_two_nn
+ not null,
+ rating integer
+ constraint cop_ratings_rating_nn
+ not null,
+ owner_id integer
+ constraint cop_ratings_owner_id_fk
+ references parties(party_id) on delete cascade
+ constraint cop_ratings_owner_id_nn
+ not null,
+ constraint cop_ratings_un
+ unique (object_one, object_two, owner_id, dimension_id)
+);
+
+comment on table cop_ratings is '
+ An object_one is related to object_two with strength rating along dimension dimension_id
+ object_two may be null in cases where the rating is unideminsional (i.e. quality
+ as opposed to relatedness for example.
+';
+
+comment on column cop_ratings.rating is '
+ An integer rating object_one along dimension (or wrt object_two along dimension
+ in the case object_two is null). Typically 1-5 although no constraint imposed.
+';
+
+
+create table cop_rating_aggregates (
+ dimension_id integer
+ constraint cop_ratings_dimension_id_fk
+ references cop_rating_dimensions(dimension_id) on delete cascade,
+ object_one integer
+ constraint cop_ratings_object_one_fk
+ references acs_objects(object_id) on delete cascade
+ constraint cop_ratings_object_one_nn
+ not null,
+ object_two integer
+ constraint cop_ratings_object_two_fk
+ references acs_objects(object_id) on delete cascade,
+ ratings integer,
+ rating_sum integer,
+ rating_ave numeric(3,1),
+ rated_on timestamptz,
+ constraint cop_rating_aggregates_pk
+ primary key (object_one, dimension_id, object_two)
+);
+
+comment on table cop_rating_aggregates is '
+ contains denormalized aggregates for the ratings table. trigger maintained by inserts and updates on cop_ratings.
+';
+
+
+select acs_object_type__create_type(
+ 'cop_rating_dimension',
+ 'COP Rating Dimension',
+ 'COP Rating Dimensions',
+ 'acs_object',
+ 'cop_rating_dimensions',
+ 'dimension_id',
+ 'cop_rating_dimension',
+ 'f',
+ null,
+ 'cop_rating_dimension__title'
+);
+
+select acs_object_type__create_type(
+ 'cop_rating',
+ 'COP Rating',
+ 'COP Ratings',
+ 'acs_object',
+ 'cop_ratings',
+ 'rating_id',
+ 'cop_rating',
+ 'f',
+ null,
+ 'cop_rating__title'
+);
+
Index: openacs-4/contrib/packages/cop-base/sql/postgresql/ratings-data.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/sql/postgresql/Attic/ratings-data.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/sql/postgresql/ratings-data.sql 28 Mar 2004 21:17:14 -0000 1.1
@@ -0,0 +1,13 @@
+-- Simple multidimensional rating package -- backing data.
+--
+-- Copyright (C) 2003 Jeff Davis
+-- @author Jeff Davis
+-- @creation-date 10/22/2003
+--
+-- @cvs-id $Id: ratings-data.sql,v 1.1 2004/03/28 21:17:14 jeffd Exp $
+--
+-- This is free software distributed under the terms of the GNU Public
+-- License. Full text of the license is available from the GNU Project:
+-- http://www.fsf.org/copyleft/gpl.html
+
+select cop_rating_dimension__new ('Quality','quality','Overall rating of an item.','f',1,5,'','best');
Index: openacs-4/contrib/packages/cop-base/sql/postgresql/ratings-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/sql/postgresql/Attic/ratings-drop.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/sql/postgresql/ratings-drop.sql 28 Mar 2004 21:17:14 -0000 1.1
@@ -0,0 +1,52 @@
+-- drop the ratings stuff
+--
+-- Copyright (C) 2003 Jeff Davis
+-- @author Jeff Davis davis@xarg.net
+-- @creation-date 10/22/2003
+--
+-- @cvs-id $Id: ratings-drop.sql,v 1.1 2004/03/28 21:17:14 jeffd Exp $
+--
+-- This is free software distributed under the terms of the GNU Public
+-- License. Full text of the license is available from the GNU Project:
+-- http://www.fsf.org/copyleft/gpl.html
+
+
+create or replace function tmp_cop_ratings_drop ()
+returns integer as '
+declare
+ coll_rec RECORD;
+begin
+ for coll_rec in select object_id
+ from acs_objects
+ where object_type = ''cop_rating_dimension''
+ loop
+ PERFORM acs_object__delete (coll_rec.object_id);
+ end loop;
+
+
+
+ for coll_rec in select object_id
+ from acs_objects
+ where object_type = ''cop_rating''
+ loop
+ PERFORM acs_object__delete (coll_rec.object_id);
+ end loop;
+
+ return 1;
+end; ' language 'plpgsql';
+
+select tmp_cop_ratings_drop ();
+drop function tmp_cop_ratings_drop ();
+
+select acs_object_type__drop_type('cop_rating_dimension', 'f');
+select acs_object_type__drop_type('cop_rating', 'f');
+
+drop table cop_rating_aggregates;
+drop table cop_ratings;
+drop table cop_rating_dimensions;
+
+select drop_package('cop_rating_dimension');
+select drop_package('cop_rating');
+
+drop function cop_ratings_upd_tr();
+drop function cop_ratings_ins_tr();
\ No newline at end of file
Index: openacs-4/contrib/packages/cop-base/sql/postgresql/ratings-procs.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/sql/postgresql/Attic/ratings-procs.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/sql/postgresql/ratings-procs.sql 28 Mar 2004 21:17:14 -0000 1.1
@@ -0,0 +1,218 @@
+-- Simple multidimensional rating package.
+--
+-- Copyright (C) 2003 Jeff Davis
+-- @author Jeff Davis
+-- @creation-date 10/22/2003
+--
+-- @cvs-id $Id: ratings-procs.sql,v 1.1 2004/03/28 21:17:14 jeffd Exp $
+--
+-- This is free software distributed under the terms of the GNU Public
+-- License. Full text of the license is available from the GNU Project:
+-- http://www.fsf.org/copyleft/gpl.html
+
+
+create or replace function cop_rating_dimension__new (integer,varchar,varchar,varchar,char(1),integer,integer,varchar,varchar,integer,timestamptz,integer,varchar,integer)
+returns integer as '
+declare
+ p_dimension_id alias for $1; -- default null
+ p_title alias for $2;
+ p_dimension_key alias for $3;
+ p_description alias for $4;
+ p_object_two_p alias for $5;
+ p_range_low alias for $6;
+ p_range_high alias for $7;
+ p_label_low alias for $8;
+ p_label_high alias for $9;
+
+ p_package_id alias for $10;
+ p_creation_date alias for $11; -- default now()
+ p_creation_user alias for $12; -- default null
+ p_creation_ip alias for $13; -- default null
+ p_context_id alias for $14; -- default null
+ v_dimension_id cop_rating_dimensions.dimension_id%TYPE;
+begin
+ v_dimension_id := acs_object__new (
+ p_dimension_id,
+ ''cop_rating_dimension'',
+ p_creation_date,
+ p_creation_user,
+ p_creation_ip,
+ p_context_id,
+ ''t'',
+ p_title,
+ p_package_id);
+
+ insert into cop_rating_dimensions (dimension_id,dimension_key,description,object_two_p,range_low,range_high,label_low,label_high)
+ values (v_dimension_id,p_dimension_key,p_description,p_object_two_p,p_range_low,p_range_high,p_label_low,p_label_high);
+
+ return v_dimension_id;
+
+end;' language 'plpgsql';
+
+-- simple api for initial populate.
+create or replace function cop_rating_dimension__new (varchar,varchar,varchar,char(1),integer,integer,varchar,varchar)
+returns integer as '
+declare
+ p_title alias for $1;
+ p_dimension_key alias for $2;
+ p_description alias for $3;
+ p_object_two_p alias for $4;
+ p_range_low alias for $5;
+ p_range_high alias for $6;
+ p_label_low alias for $7;
+ p_label_high alias for $8;
+begin
+ return cop_rating_dimension__new(null,p_title,p_dimension_key,p_description,p_object_two_p,p_range_low,p_range_high,p_label_low,p_label_high,null,now(),null,null,null);
+end;' language 'plpgsql';
+
+
+create or replace function cop_rating_dimension__delete (integer)
+returns integer as '
+declare
+ p_dimension_id alias for $1;
+begin
+ if exists (select 1 from acs_objects where object_id = p_dimension_id and object_type = ''cop_rating_dimension'') then
+ delete from acs_permissions
+ where object_id = p_dimension_id;
+
+ PERFORM acs_object__delete(p_dimension_id);
+
+ return 0;
+ else
+ raise NOTICE ''cop_dimension__delete object_id % does not exist or is not a cop_rating_dimension'',p_dimension_id;
+ return 0;
+ end if;
+end;' language 'plpgsql';
+
+
+create or replace function cop_rating_dimension__title (integer)
+returns varchar as '
+declare
+ p_dimension_id alias for $1;
+ v_title varchar;
+begin
+ SELECT title into v_title
+ FROM acs_objects
+ WHERE object_id = p_dimension_id
+ and object_type = ''cop_rating_dimension'';
+
+ return v_title;
+end;
+' language 'plpgsql';
+
+
+
+create or replace function cop_rating__new (integer,integer,integer,integer,integer,varchar,integer,timestamptz,integer,varchar,integer)
+returns integer as '
+declare
+ p_rating_id alias for $1;
+ p_dimension_id alias for $2;
+ p_object_one alias for $3;
+ p_object_two alias for $4;
+ p_rating alias for $5;
+ p_title alias for $6;
+ p_package_id alias for $7;
+ p_creation_date alias for $8;
+ p_creation_user alias for $9;
+ p_creation_ip alias for $10;
+ p_context_id alias for $11;
+ v_rating_id cop_ratings.rating_id%TYPE;
+begin
+ v_rating_id := acs_object__new (
+ p_rating_id,
+ ''cop_rating'',
+ p_creation_date,
+ p_creation_user,
+ p_creation_ip,
+ p_context_id,
+ ''t'',
+ p_title,
+ p_package_id);
+
+ INSERT INTO cop_ratings (rating_id,dimension_id,object_one,object_two,rating,owner_id)
+ VALUES (v_rating_id,p_dimension_id,p_object_one,p_object_two,p_rating,p_creation_user);
+
+ return v_rating_id;
+end;' language 'plpgsql';
+
+
+create or replace function cop_rating__delete (integer)
+returns integer as '
+declare
+ p_rating_id alias for $1;
+begin
+ if exists (select 1 from acs_objects where object_id = p_rating_id and object_type = ''cop_rating'') then
+ delete from acs_permissions
+ where object_id = p_rating_id;
+
+ PERFORM acs_object__delete(p_rating_id);
+
+ return 0;
+ else
+ raise NOTICE ''cop_rating__delete object_id % does not exist or is not a cop_rating'',p_rating_id;
+ return -1;
+ end if;
+end;' language 'plpgsql';
+
+
+create or replace function cop_rating__title (integer)
+returns varchar as '
+declare
+ p_rating_id alias for $1;
+ v_title varchar;
+begin
+ SELECT title into v_title
+ FROM acs_objects
+ WHERE object_id = p_rating_id
+ and object_type = ''cop_rating'';
+
+ return v_title;
+end;' language 'plpgsql';
+
+
+create or replace function cop_rating__rate(integer,integer,integer,integer,varchar,integer,timestamptz,integer,varchar,integer)
+returns integer as '
+declare
+ p_dimension_id alias for $1;
+ p_object_one alias for $2;
+ p_object_two alias for $3;
+ p_rating alias for $4;
+ p_title alias for $5;
+ p_package_id alias for $6;
+ p_date alias for $7;
+ p_user alias for $8;
+ p_ip alias for $9;
+ p_context_id alias for $10;
+ v_rating_id cop_ratings.rating_id%TYPE;
+ v_object_two cop_ratings.object_two%TYPE;
+begin
+ if p_object_two is null then
+ v_object_two = p_dimension_id;
+ else
+ v_object_two = p_object_two;
+ end if;
+
+ SELECT rating_id into v_rating_id
+ FROM cop_ratings
+ WHERE dimension_id = p_dimension_id
+ and object_one = p_object_one
+ and object_two = v_object_two
+ and owner_id = p_user;
+
+ if v_rating_id is null then
+ PERFORM cop_rating__new(null, p_dimension_id, p_object_one, v_object_two, p_rating, p_title, p_package_id, p_date, p_user, p_ip, p_context_id);
+ else
+ UPDATE cop_ratings
+ SET rating = p_rating
+ WHERE rating_id = v_rating_id;
+
+
+ UPDATE acs_objects
+ SET last_modified = coalesce(p_date,now()), modifying_user = p_user, modifying_ip = p_ip
+ WHERE object_id = v_rating_id;
+ end if;
+
+ return v_rating_id;
+end;' language 'plpgsql';
+
+select define_function_args('cop_rating__rate','dimension_id, object_one, object_two, rating, title, package_id, rated_on;now(), user_id, ip, context_id');
\ No newline at end of file
Index: openacs-4/contrib/packages/cop-base/sql/postgresql/ratings-triggers.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/sql/postgresql/Attic/ratings-triggers.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/sql/postgresql/ratings-triggers.sql 28 Mar 2004 21:17:14 -0000 1.1
@@ -0,0 +1,80 @@
+-- COP Rating denorm triggers
+--
+-- Copyright (C) 2003 Jeff Davis
+-- @author Jeff Davis
+-- @creation-date 1/12/2003
+--
+-- @cvs-id $Id: ratings-triggers.sql,v 1.1 2004/03/28 21:17:14 jeffd Exp $
+--
+-- This is free software distributed under the terms of the GNU Public
+-- License. Full text of the license is available from the GNU Project:
+-- http://www.fsf.org/copyleft/gpl.html
+
+create function cop_ratings_ins_tr () returns opaque as '
+begin
+ if not exists (
+ SELECT 1
+ FROM cop_rating_aggregates
+ WHERE dimension_id = new.dimension_id
+ and object_one = new.object_one
+ and object_two = new.object_two) then
+
+ INSERT INTO cop_rating_aggregates (dimension_id, object_one, object_two, ratings, rating_sum, rating_ave, rated_on)
+ VALUES (new.dimension_id, new.object_one, new.object_two, 1, new.rating, new.rating, now());
+
+ else
+
+ UPDATE cop_rating_aggregates
+ SET ratings = ratings + 1, rating_sum = rating_sum + new.rating,
+ rating_ave = (rating_sum + new.rating)/(ratings + 1), rated_on = now()
+ WHERE dimension_id = new.dimension_id
+ and object_one = new.object_one
+ and object_two = new.object_two;
+
+ end if;
+
+ return new;
+end;' language 'plpgsql';
+
+create trigger cop_ratings_ins_tr
+after insert on cop_ratings
+for each row
+execute procedure cop_ratings_ins_tr();
+
+create function cop_ratings_upd_tr () returns opaque as '
+begin
+ UPDATE cop_rating_aggregates
+ SET rating_sum = rating_sum - coalesce(old.rating,1) + coalesce(new.rating,1),
+ rating_ave = (rating_sum - coalesce(old.rating,1) + coalesce(new.rating,1))/ratings,
+ rated_on = now()
+ WHERE dimension_id = new.dimension_id
+ and object_one = new.object_one
+ and object_two = new.object_two;
+
+ return new;
+
+end;' language 'plpgsql';
+
+create trigger cop_ratings_upd_tr
+after update on cop_ratings
+for each row
+execute procedure cop_ratings_upd_tr();
+
+-- drop function cop_ratings_del_tr() cascade;
+create function cop_ratings_del_tr () returns opaque as '
+begin
+ UPDATE cop_rating_aggregates
+ SET ratings = (case when ratings > 0 then ratings - 1 else 0 end),
+ rating_sum = (case when rating_sum - coalesce(old.rating,1) > 0 then rating_sum - coalesce(old.rating,1) else 0 end),
+ rating_ave = (rating_sum - coalesce(old.rating,1))/(case when ratings > 1 then ratings - 1 else 1 end)
+ WHERE dimension_id = old.dimension_id
+ and object_one = old.object_one
+ and object_two = old.object_two;
+
+ return old;
+end;' language 'plpgsql';
+
+create trigger cop_ratings_del_tr
+after delete on cop_ratings
+for each row
+execute procedure cop_ratings_del_tr();
Index: openacs-4/contrib/packages/cop-base/sql/postgresql/relations-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/sql/postgresql/Attic/relations-create.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/sql/postgresql/relations-create.sql 28 Mar 2004 21:17:14 -0000 1.1
@@ -0,0 +1,80 @@
+-- Relate items the openacs way!
+--
+-- Copyright (C) 2003 Jeff Davis
+-- @author Jeff Davis
+-- @creation-date 10/22/2003
+--
+-- @cvs-id $Id: relations-create.sql,v 1.1 2004/03/28 21:17:14 jeffd Exp $
+--
+-- This is free software distributed under the terms of the GNU Public
+-- License. Full text of the license is available from the GNU Project:
+-- http://www.fsf.org/copyleft/gpl.html
+
+create table cop_rels (
+ rel_id integer references acs_rels(rel_id)
+);
+
+comment on table cop_rels is 'stupid table';
+
+select acs_object_type__create_type(
+ 'cop_rel',
+ 'COP Related Item',
+ 'COP Related Items',
+ 'relationship',
+ 'cop_rels',
+ 'rel_id',
+ 'cop_rel',
+ 'f',
+ 'cop_rel__title',
+ null
+);
+
+insert into acs_rel_types (rel_type, object_type_one, role_one, min_n_rels_one, max_n_rels_one, object_type_two, role_two, min_n_rels_two, max_n_rels_two)
+values ('cop_rel','acs_object',null,0,null,'acs_object',null,0,null);
+
+
+create or replace function cop_rel__new (integer,integer,integer,integer,integer,varchar)
+returns integer as '
+declare
+ new_rel_id alias for $1; -- default null
+ object_id_one alias for $2;
+ object_id_two alias for $3;
+ context_id alias for $4; -- default null
+ creation_user alias for $5; -- default null
+ creation_ip alias for $6; -- default null
+ v_rel_id acs_rels.rel_id%TYPE;
+begin
+ v_rel_id := acs_rel__new(new_rel_id, ''cop_rel'',object_id_one, object_id_two, context_id, creation_user, creation_ip);
+
+ insert into cop_rels(rel_id) values (v_rel_id);
+
+ return v_rel_id;
+
+end;' language 'plpgsql';
+
+
+create or replace function cop_rel__delete(integer)
+returns integer as '
+declare
+ rel_id alias for $1;
+begin
+ PERFORM acs_object__delete(rel_id);
+
+ return 0;
+end;' language 'plpgsql';
+
+
+
+create or replace function cop_rel__title(integer)
+returns varchar as '
+declare
+ rel_id alias for $1;
+ v_title acs_objects.title%TYPE;
+begin
+ select title into v_title from acs_objects where object_id = rel_id and object_type = ''cop_rel'';
+ return v_title;
+end;' language 'plpgsql';
+
+select define_function_args('cop_rel__new','rel_id,object_id_one,object_id_two,context_id,creation_user,creation_ip');
+select define_function_args('cop_rel__title','rel_id');
+select define_function_args('cop_rel__delete','rel_id');
Index: openacs-4/contrib/packages/cop-base/sql/postgresql/relations-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/sql/postgresql/Attic/relations-drop.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/sql/postgresql/relations-drop.sql 28 Mar 2004 21:17:14 -0000 1.1
@@ -0,0 +1,39 @@
+-- Drop the relations data package and tables.
+--
+-- Copyright (C) 2003 Jeff Davis
+-- @author Jeff Davis davis@xarg.net
+-- @creation-date 10/22/2003
+--
+-- @cvs-id $Id: relations-drop.sql,v 1.1 2004/03/28 21:17:14 jeffd Exp $
+--
+-- This is free software distributed under the terms of the GNU Public
+-- License. Full text of the license is available from the GNU Project:
+-- http://www.fsf.org/copyleft/gpl.html
+
+delete from acs_rel_types where rel_type = 'cop_rel';
+
+create or replace function tmp_cop_relations_delete ()
+returns integer as '
+declare
+ coll_rec RECORD;
+begin
+ for coll_rec in select object_id
+ from acs_objects
+ where object_type = ''cop_rel''
+ loop
+ PERFORM acs_object__delete (coll_rec.object_id);
+ end loop;
+
+ return 1;
+end; ' language 'plpgsql';
+
+select tmp_cop_relations_delete ();
+drop function tmp_cop_relations_delete ();
+
+select acs_object_type__drop_type('cop_rel', 'f');
+drop table cop_rels;
+
+
+select drop_package('cop_rel');
+
+
Index: openacs-4/contrib/packages/cop-base/sql/postgresql/views-create.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/sql/postgresql/Attic/views-create.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/sql/postgresql/views-create.sql 28 Mar 2004 21:17:14 -0000 1.1
@@ -0,0 +1,61 @@
+-- Tracking and aggregating object views...
+--
+-- Copyright (C) 2003 Jeff Davis
+-- @author Jeff Davis
+-- @creation-date 1/12/2003
+--
+-- @cvs-id $Id: views-create.sql,v 1.1 2004/03/28 21:17:14 jeffd Exp $
+--
+-- This is free software distributed under the terms of the GNU Public
+-- License. Full text of the license is available from the GNU Project:
+-- http://www.fsf.org/copyleft/gpl.html
+
+create table cop_object_views (
+ object_id integer
+ constraint cop_object_views_object_id_fk
+ references acs_objects(object_id) on delete cascade
+ constraint cop_object_views_object_id_nn
+ not null,
+ viewer_id integer
+ constraint cop_object_views_owner_id_fk
+ references parties(party_id) on delete cascade
+ constraint cop_object_views_viewer_id_nn
+ not null,
+ views integer default 1,
+ last_viewed timestamptz default now(),
+ constraint cop_object_views_pk
+ primary key (object_id, viewer_id)
+);
+
+create unique index cop_object_views_viewer_idx on cop_object_views(viewer_id, object_id);
+
+comment on table cop_object_views is '
+ a simple count of how many times an object is viewed.
+';
+
+create table cop_object_view_agg (
+ object_id integer
+ constraint cop_object_views_object_id_fk
+ references acs_objects(object_id) on delete cascade
+ constraint cop_object_views_object_id_nn
+ not null
+ constraint cop_object_view_agg_pk
+ primary key,
+ views integer default 1,
+ unique_views integer default 1,
+ last_viewed timestamptz default now()
+);
+
+comment on table cop_object_views is '
+ a simple count of how many times an object is viewed, multiple visits
+ trigger maintained by updates on cop_object_views.
+';
+
+
+
+
+
+
+
+
+
Index: openacs-4/contrib/packages/cop-base/sql/postgresql/views-drop.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/sql/postgresql/Attic/views-drop.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/sql/postgresql/views-drop.sql 28 Mar 2004 21:17:14 -0000 1.1
@@ -0,0 +1,18 @@
+-- drop the tracking and aggregating object views...
+--
+-- Copyright (C) 2003 Jeff Davis
+-- @author Jeff Davis davis@xarg.net
+-- @creation-date 10/22/2003
+--
+-- @cvs-id $Id: views-drop.sql,v 1.1 2004/03/28 21:17:14 jeffd Exp $
+--
+-- This is free software distributed under the terms of the GNU Public
+-- License. Full text of the license is available from the GNU Project:
+-- http://www.fsf.org/copyleft/gpl.html
+
+drop function cop_object_record_view (integer, integer);
+drop function cop_object_views_upd_tr();
+drop function cop_object_views_ins_tr();
+drop table cop_object_view_agg;
+drop table cop_object_views;
+
Index: openacs-4/contrib/packages/cop-base/sql/postgresql/views-procs.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/sql/postgresql/Attic/views-procs.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/sql/postgresql/views-procs.sql 28 Mar 2004 21:17:14 -0000 1.1
@@ -0,0 +1,31 @@
+-- Tracking and aggregating object views -- procedures.
+--
+-- Copyright (C) 2003 Jeff Davis
+-- @author Jeff Davis
+-- @creation-date 1/12/2003
+--
+-- @cvs-id $Id: views-procs.sql,v 1.1 2004/03/28 21:17:14 jeffd Exp $
+--
+-- This is free software distributed under the terms of the GNU Public
+-- License. Full text of the license is available from the GNU Project:
+-- http://www.fsf.org/copyleft/gpl.html
+
+create or replace function cop_object_record_view (integer, integer) returns integer as '
+declare
+ p_object_id alias for $1;
+ p_viewer_id alias for $2;
+begin
+ if not exists (select 1 from cop_object_views where object_id = p_object_id and viewer_id = p_viewer_id) then
+ INSERT into cop_object_views(object_id,viewer_id)
+ VALUES (p_object_id, p_viewer_id);
+ else
+ UPDATE cop_object_views
+ SET views = views + 1, last_viewed = now()
+ WHERE object_id = p_object_id
+ and viewer_id = p_viewer_id;
+ end if;
+
+ return 0;
+end;' language 'plpgsql';
+
+
Index: openacs-4/contrib/packages/cop-base/sql/postgresql/views-triggers.sql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/sql/postgresql/Attic/views-triggers.sql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/sql/postgresql/views-triggers.sql 28 Mar 2004 21:17:14 -0000 1.1
@@ -0,0 +1,44 @@
+-- Tracking and aggregating object views - triggers for denormalization
+--
+-- Copyright (C) 2003 Jeff Davis
+-- @author Jeff Davis
+-- @creation-date 1/12/2003
+--
+-- @cvs-id $Id: views-triggers.sql,v 1.1 2004/03/28 21:17:14 jeffd Exp $
+--
+-- This is free software distributed under the terms of the GNU Public
+-- License. Full text of the license is available from the GNU Project:
+-- http://www.fsf.org/copyleft/gpl.html
+
+create function cop_object_views_ins_tr () returns opaque as '
+begin
+ if not exists (select 1 from cop_object_view_agg where object_id = new.object_id) then
+ INSERT INTO cop_object_view_agg (object_id,views,unique_views,last_viewed)
+ VALUES (new.object_id,1,1,now());
+ else
+ UPDATE cop_object_view_agg
+ SET views = views + 1, unique_views = unique_views + 1, last_viewed = now()
+ WHERE object_id = new.object_id;
+ end if;
+
+ return new;
+end;' language 'plpgsql';
+
+create trigger cop_object_views_ins_tr
+after insert on cop_object_views
+for each row
+execute procedure cop_object_views_ins_tr();
+
+create function cop_object_views_upd_tr () returns opaque as '
+begin
+ UPDATE cop_object_view_agg
+ SET views = views + 1, last_viewed = now()
+ WHERE object_id = new.object_id;
+
+ return new;
+end;' language 'plpgsql';
+
+create trigger cop_object_views_upd_tr
+after update on cop_object_views
+for each row
+execute procedure cop_object_views_upd_tr();
Index: openacs-4/contrib/packages/cop-base/tcl/clipboard-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/tcl/Attic/clipboard-procs-postgresql.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/tcl/clipboard-procs-postgresql.xql 28 Mar 2004 21:17:14 -0000 1.1
@@ -0,0 +1,43 @@
+
+
+
+ postgresql7.1
+
+
+
+
+select cop_clipboard__new(:clipboard_id, :owner_id, :title, :package_id, now(), :creation_user_id, :peeraddr, :context)
+
+
+
+
+
+
+
+select cop_clipboard__delete(:clipboard_id)
+
+
+
+
+
+
+
+ INSERT into cop_clipboard_object_map(clipboard_id, object_id, clipped_on)
+ SELECT :clipboard_id, :object_id, now()
+ WHERE acs_permission__permission_p(:clipboard_id, :user_id, 'write') = 't'
+
+
+
+
+
+
+
+ DELETE FROM cop_clipboard_object_map
+ WHERE acs_permission__permission_p(:clipboard_id, :user_id, 'write') = 't'
+ and clipboard_id = :clipboard_id
+ and object_id = :object_id
+
+
+
+
+
Index: openacs-4/contrib/packages/cop-base/tcl/clipboard-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/tcl/Attic/clipboard-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/tcl/clipboard-procs.tcl 28 Mar 2004 21:17:14 -0000 1.1
@@ -0,0 +1,169 @@
+# /packages/cop-base/tcl/clipboard-procs.tcl
+ad_library {
+ TCL library for the COP clipboard
+
+ @author Jeff Davis
+
+ @creation-date 10/23/2003
+ @cvs-id $Id: clipboard-procs.tcl,v 1.1 2004/03/28 21:17:14 jeffd Exp $
+}
+
+namespace eval cop {}
+namespace eval cop::clipboard {}
+
+ad_proc -public cop::clipboard::clipboards {
+ -count:boolean
+ -create_new:boolean
+ -force_default:boolean
+ user_id
+ datasource
+} {
+ creates a multirow datasource with the existing clipboards
+
+ @param create_new add a "Create new folder" entry to list
+ @param force_default create the datasource with a default folder even if none exist
+ @param user_id the owner id for the folders
+ @param datasource the datasource name to use.
+
+
+ @return count of rows found, multirow created at adp_level
+
+ @author Jeff Davis davis@xarg.net
+ @creation-date 2003-10-30
+} {
+ if {!$count_p} {
+ db_multirow $datasource clipboards {
+ SELECT c.clipboard_id, o.title, 0 as selected, 0 as clipped
+ FROM acs_objects o, cop_clipboards c
+ WHERE c.owner_id = :user_id
+ and o.object_id = c.clipboard_id
+ }
+ } else {
+ db_multirow $datasource clipboards_count {
+ SELECT c.clipboard_id, o.title, 0 as selected, coalesce(n.clipped,0) as clipped, to_char(last_clip,'YYYY-MM-DD HH24:MI:SS') as last_clip
+ FROM acs_objects o, cop_clipboards c left join (select clipboard_id, count(*) as clipped, max(clipped_on) as last_clip from cop_clipboard_object_map where clipboard_id in (select clipboard_id from cop_clipboards where owner_id = :user_id) group by clipboard_id) n on n.clipboard_id = c.clipboard_id
+ WHERE c.owner_id = :user_id
+ and o.object_id = c.clipboard_id
+ } {
+ set last_clip [util::age_pretty -timestamp_ansi $last_clip -sysdate_ansi [clock_to_ansi [clock seconds]]]
+ }
+ }
+
+ if {[template::multirow size $datasource] > 0} {
+ if {$create_new_p} {
+ template::multirow append $datasource -1 "Create a new clipboard" 0
+ }
+ } else {
+ if { $force_default_p } {
+ template::multirow create $datasource clipboard_id title selected
+ template::multirow append $datasource 0 "General" 0
+ }
+ }
+ return [template::multirow size $datasource]
+}
+
+
+ad_proc -public cop::clipboard::clipped {
+ object_id
+ user_id
+ datasource
+} {
+ creates a multirow with the list of clipboards to which you
+ have attached an object.
+
+ @param user_id the owner id to check for.
+ @param object_id the object which is clipped.
+ @param datasource the datasource name to use.
+
+ @return count of rows found, multirow created at adp_level
+
+ @author Jeff Davis davis@xarg.net
+ @creation-date 2003-10-30
+} {
+ db_multirow $datasource clipped {
+ select c.clipboard_id, o.title
+ from cop_clipboards c, cop_clipboard_object_map m, acs_objects o
+ where m.object_id = :object_id
+ and m.clipboard_id = c.clipboard_id
+ and o.object_id = m.clipboard_id
+ and owner_id = :user_id
+ order by lower(o.title)
+ }
+
+ return [template::multirow size $datasource]
+}
+
+
+ad_proc -public cop::clipboard::new {
+ -clipboard_id
+ -owner_id
+ -title:required
+ -package_id
+ -creation_user_id
+ -peeraddr
+ -context
+} {
+ create a new clipboard.
+} {
+ if {![exists_and_not_null clipboard_id]} {
+ set clipboard_id [db_nextval acs_object_id_seq]
+ }
+
+ # should check for connected and if not fill in sensible
+ # stuff and barf on absence of owner_id.
+
+ if {![exists_and_not_null owner_id]} {
+ set owner_id [ad_conn user_id]
+ }
+ if {![exists_and_not_null peeraddr]} {
+ set peeraddr [ad_conn peeraddr]
+ }
+ if {![exists_and_not_null context]} {
+ set context [ad_conn package_id]
+ }
+ if {![exists_and_not_null package_id]} {
+ set package_id [ad_conn package_id]
+ }
+ if {![exists_and_not_null creation_user_id]} {
+ set creation_user_id [ad_conn user_id]
+ }
+
+ db_exec_plsql new_clipboard {*SQL*}
+}
+
+ad_proc -public cop::clipboard::delete {
+ -clipboard_id
+} {
+ create a new clipboard.
+} {
+ db_exec_plsql delete_clipboard {*SQL*}
+}
+
+
+
+
+ad_proc -public cop::clipboard::attach {
+ -clipboard_id:required
+ -object_id:required
+ -user_id:required
+} {
+ attach an item to a clipboard
+} {
+ if {[catch {db_dml map_object {}} errMsg]} {
+ # Check if it was a pk violation (i.e. already inserted)
+ if {![string match "*cop_clipboard_object_map_pk*" $errMsg]} {
+ ad_return_error "Clipboard Insert error" "Error putting object into clipboard (query name map_object)
$errMsg
"
+ ad_script_abort
+ }
+ }
+}
+
+ad_proc -public cop::clipboard::remove {
+ -clipboard_id:required
+ -object_id:required
+ -user_id:required
+} {
+ remove item from a clipboard
+} {
+ db_dml unmap_object {}
+}
\ No newline at end of file
Index: openacs-4/contrib/packages/cop-base/tcl/cop-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/tcl/cop-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/tcl/cop-procs.tcl 28 Mar 2004 21:17:14 -0000 1.1
@@ -0,0 +1,31 @@
+# /packages/cop-base/tcl/clipboard-procs.tcl
+ad_library {
+ TCL library for the COP package
+
+ @author Jeff Davis
+
+ @creation-date 10/23/2003
+ @cvs-id $Id: cop-procs.tcl,v 1.1 2004/03/28 21:17:14 jeffd Exp $
+}
+
+namespace eval cop {}
+namespace eval cop::util {}
+
+ad_proc -public cop::util::url {
+ {-subsite_id {}}
+} {
+ Returns the cop-ui URL for a given subsite.
+
+ @param subsite_id the subsite for which to find the cop-ui url
+
+ @return a url for the cop-ui package
+
+ @author Jeff Davis davis@xarg.net
+ @creation-date 2003-10-30
+} {
+ if {[empty_string_p $subsite_id]} {
+ set subsite_id [ad_conn subsite_id]
+ }
+
+ return [lindex [site_node::get_children -node_id $subsite_id -package_key cop-ui -all] 0]
+}
\ No newline at end of file
Index: openacs-4/contrib/packages/cop-base/tcl/rating-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/tcl/Attic/rating-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/tcl/rating-procs.tcl 28 Mar 2004 21:17:14 -0000 1.1
@@ -0,0 +1,187 @@
+# /packages/cop-base/tcl/ratings-procs.tcl
+ad_library {
+ TCL library for the COP ratings
+
+ @author Jeff Davis
+
+ @creation-date 10/23/2003
+ @cvs-id $Id: rating-procs.tcl,v 1.1 2004/03/28 21:17:14 jeffd Exp $
+}
+
+namespace eval cop {}
+namespace eval cop::rating {}
+namespace eval cop::rating::aggregate {}
+namespace eval cop::rating::dimension {}
+
+ad_proc -public cop::rating::aggregate::get {
+ {-dimension_key "quality"}
+ {-object_two ""}
+ -object_one
+} {
+ returns array set ratings info for ratings on the given
+ object_id along dimension dimension_key
+
+ @param dimension_key
+ @param object_id
+
+ @return array set info on ratings for object $object_id
+
+ @author Jeff Davis davis@xarg.net
+ @creation-date 2004-01-30
+} {
+ array set dim [cop::rating::dimension::get -dimension_key $dimension_key]
+ set dimension_id $dim(dimension_id)
+ if {!$dim(object_two_p)} {
+ if { [db_0or1row get_ratings {
+ SELECT rating_ave, rating_sum, ratings
+ FROM cop_rating_aggregates
+ WHERE dimension_id = :dimension_id
+ and object_one = :object_one
+ and object_two = :dimension_id } -column_array ret] } {
+ return [array get ret]
+ }
+ } else {
+ if { [db_0or1rows get_ratings {
+ SELECT rating_ave, ratings
+ FROM cop_rating_aggregates
+ WHERE dimension_id = :dimension_id
+ and object_one = :object_one
+ and object_two = :object_two } -column_array ret] } {
+ return [array get ret]
+ }
+ }
+ return {}
+}
+
+ad_proc -public cop::rating::get {
+ {-dimension_key "quality"}
+ {-object_two {}}
+ -object_one
+ -user_id
+} {
+ Returns the rating given by the passed in user.
+
+ @return the rating or empty string if unrated.
+
+ @author Jeff Davis davis@xarg.net
+ @creation-date 2004-01-30
+} {
+ if {[empty_string_p $object_two]} {
+ return [db_string get_rating {
+ SELECT rating
+ FROM cop_ratings
+ WHERE dimension_id = (select dimension_id from cop_rating_dimensions where dimension_key = :dimension_key)
+ and object_one = :object_one
+ and owner_id = :user_id
+ and object_two = (select dimension_id from cop_rating_dimensions where dimension_key = :dimension_key)} -default {} ]
+ } else {
+ error "cop::rating::get: object_two non null not yet supported"
+ }
+}
+
+
+ad_proc -public cop::rating::dimension::get {
+ -dimension_key
+} {
+ Retrieve the dimension data for the given dimension_key
+
+ @author Jeff Davis davis@xarg.net
+ @creation-date 2004-01
+} {
+ db_1row get {select * from cop_rating_dimensions where dimension_key = :dimension_key} -column_array ret
+
+ return [array get ret]
+}
+
+
+
+ad_proc -public cop::rating::widget {
+ {-dimension_key "quality"}
+ {-user_id {}}
+ {-object_one {}}
+ {-object_two {}}
+} {
+ Create a rating widget; returns an html fragment with the form defined.
+
+ @author Jeff Davis davis@xarg.net
+ @creation-date 2004-01-30
+} {
+ array set dim [cop::rating::dimension::get -dimension_key $dimension_key]
+
+ if {![info exists dim(dimension_key)]} {
+ error "cop::rating::widget: invalid dimension_key $dimension_key"
+ }
+
+ if {![empty_string_p $object_one]
+ && [empty_string_p $user_id]} {
+ set user_id [ad_conn user_id]
+ }
+
+ if {![empty_string_p $object_one]} {
+ set rating [cop::rating::get \
+ -dimension_key $dimension_key \
+ -object_one $object_one \
+ -object_two $object_two \
+ -user_id $user_id ]
+ } else {
+ set rating {}
+ }
+
+ set out "\n"
+ } else {
+ append out "\n\n\n"
+ }
+}
+
+
+ad_proc -public cop::rating::rate {
+ {-dimension_key "quality"}
+ {-object_two {}}
+ -object_one
+ -user_id
+ -rating
+} {
+ Sets the rating for object_one for user user_id.
+
+ @author Jeff Davis davis@xarg.net
+ @creation-date 2004-01-30
+} {
+ array set dim [cop::rating::dimension::get -dimension_key $dimension_key]
+ set dimension_id $dim(dimension_id)
+
+ set vars [list \
+ [list dimension_id $dimension_id] \
+ [list object_one $object_one] \
+ [list object_two $object_two] \
+ [list rating $rating] \
+ [list title "Rating $dimension_key by $user_id on $object_one to $object_two"] \
+ [list package_id [ad_conn package_id]] \
+ [list user_id $user_id] \
+ [list ip [ad_conn peeraddr]] \
+ ]
+
+ package_exec_plsql -var_list $vars cop_rating rate
+}
+
+ad_proc -public cop::rating::icon_base {} {
+ return the base url for the rating icons
+} {
+ return /resources/cop-ui/small/
+}
Index: openacs-4/contrib/packages/cop-base/tcl/relation-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/tcl/Attic/relation-procs.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-base/tcl/relation-procs.tcl 28 Mar 2004 21:17:14 -0000 1.1
@@ -0,0 +1,39 @@
+# /packages/cop-base/tcl/relation-procs.tcl
+ad_library {
+ TCL library for the COP relations
+
+ @author Jeff Davis
+
+ @creation-date 10/23/2003
+ @cvs-id $Id: relation-procs.tcl,v 1.1 2004/03/28 21:17:14 jeffd Exp $
+}
+
+namespace eval cop {}
+namespace eval cop::relation {}
+
+ad_proc -public cop::relation::get_related {
+ -object_id
+ -datasource
+} {
+ sets a multirow with the related items for object_id
+
+ @return number of related items + multirow created as side effect
+ @author Jeff Davis davis@xarg.net
+ @creation-date 2004-01-30
+} {
+ db_multirow $datasource related {
+ SELECT ar.rel_id,
+ (case when ar.object_id_one = :object_id then ar.object_id_two else ar.object_id_one end) as object_id,
+ to_char(ro.creation_date,'YYYY-MM-DD HH24:MI') as related_on,
+ coalesce(o1.title,'? '||o1.object_type||o1.object_id) as object_title,
+ person__name(ro.creation_user) as name
+ FROM cop_rels r, acs_objects o1, acs_rels ar, acs_objects ro
+ WHERE o1.object_id = (case when ar.object_id_one = :object_id then ar.object_id_two else ar.object_id_one end)
+ and ar.rel_id = r.rel_id
+ and ro.object_id = r.rel_id
+ and (ar.object_id_one = :object_id or ar.object_id_two = :object_id)
+ }
+
+ return [template::multirow size $datasource]
+}
+
Index: openacs-4/contrib/packages/cop-ui/cop-ui.info
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/cop-ui.info,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-ui/cop-ui.info 28 Mar 2004 21:17:09 -0000 1.1
@@ -0,0 +1,25 @@
+
+
+
+
+ COP UI
+ COP UI`
+ f
+ f
+ cop
+
+
+ Jeff Davis
+ Commmunity of practice UI including admin functions.
+ Xarg
+
+
+
+
+
+
+
+
+
+
+
Index: openacs-4/contrib/packages/cop-ui/www/index.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/index.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/contrib/packages/cop-ui/www/index.adp 28 Mar 2004 21:17:10 -0000 1.1
@@ -0,0 +1,10 @@
+
+ COP HOME
+ cop
+
+