Index: openacs-4/contrib/packages/cop-base/cop-base.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/cop-base.info,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-base/cop-base.info 28 Mar 2004 21:17:13 -0000 1.1 @@ -0,0 +1,26 @@ + + + + + COP Base + COP Bases + f + t + cop-base + + + Jeff Davis + Community of Practice base package + Xarg + Provides datamodel, utility functions, includelets, and documentation for the Community of practice tools. + + + + + + + + + + + Index: openacs-4/contrib/packages/cop-base/lib/cop-footer.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-base/lib/cop-footer.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-base/lib/cop-footer.adp 28 Mar 2004 21:17:13 -0000 1.1 @@ -0,0 +1,81 @@ +
+ object: @displayed_object_id@ package_id: @cur_pkg@ acs_obj.package_id: @obj_pkg@ name: @tname@
+ acs_object.title: @obj_title@
+ acs_object__name: @acs_name@
+ +
+
+ + View All clipboards + + + + Clip this item + + + + Clip this item to folder +
+ + + +
+
+ +
This item is clipped to: + + @clipped.title@ remove  + +
+
+
+ +
+
+ Views: @views@ Unique visitors: @unique_views@ +
+
+ +
+
+ Rating: @ratings.ratings@Unrated  +  Yours: Change:  Rate: @rate_form;noquote@ +
+
+ +
+
+ @comment_link;noquote@ +
+
+
+
+ + + + Relate +
+
+
+
+ + @catass_list@ +
+
+ +
+
+ offsite links, Search, RSS, notifications. +
+
+ +
@foo@
+
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[export_vars -form {object_one object_two dimension_key}]\n
\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 + + Index: openacs-4/contrib/packages/cop-ui/www/categories/map.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/categories/map.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/categories/map.adp 28 Mar 2004 21:17:10 -0000 1.1 @@ -0,0 +1 @@ +OK \ No newline at end of file Index: openacs-4/contrib/packages/cop-ui/www/categories/map.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/categories/map.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/categories/map.tcl 28 Mar 2004 21:17:10 -0000 1.1 @@ -0,0 +1,23 @@ +ad_page_contract { +} { + object_id:integer,notnull + container_id:integer,notnull +} + +ad_form -name catass -form { + {object_id:integer(hidden) + {value $object_id} + } + {container_id:integer(hidden) + {value $container_id} + } +} +category::ad_form::add_widgets -container_object_id $container_id -form_name catass +ad_form -extend -name catass -on_submit { + ns_log Notice "JCD: trees [category_tree::get_mapped_trees $container_id]" + set category_ids [category::ad_form::get_categories -container_object_id $container_id] + ns_log Notice "JCD: mapping $category_ids" + category::map_object \ + -object_id $object_id \ + $category_ids +} Index: openacs-4/contrib/packages/cop-ui/www/clipboards/ae.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/clipboards/ae.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/clipboards/ae.adp 28 Mar 2004 21:17:10 -0000 1.1 @@ -0,0 +1,6 @@ + +Clipboard +{./ clipboards} add/edit + + + Index: openacs-4/contrib/packages/cop-ui/www/clipboards/ae.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/clipboards/ae.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/clipboards/ae.tcl 28 Mar 2004 21:17:10 -0000 1.1 @@ -0,0 +1,44 @@ +# /packages/cop-ui/www/clipboard/ae.tcl +ad_page_contract { + add/edit an object clipboard and optionally attach an + object at the same time. + + @author Jeff Davis davis@xarg.net + @creation-date 10/30/2003 + @cvs-id $Id: ae.tcl,v 1.1 2004/03/28 21:17:10 jeffd Exp $ +} { + clipboard_id:optional + {object_id:integer,optional {}} +} + +set user_id [auth::require_login] + +ad_form -name clip_ae -export {object_id} -form { + clipboard_id:key(acs_object_id_seq) + {title:text(text) {label "Clipboard name"} + {html {size 60}}} +} -select_query { + select title from acs_objects where object_id = :clipboard_id and object_type = 'cop_clipboard' +} -validate { + {title + {![string is space $title]} + "You must provide a name for the clipboard" + } +} -new_data { + cop::clipboard::new -title $title +} -edit_data { + set peeraddr [ad_conn peeraddr] + permission::require_permission -object_id $clipboard_id -privilege admin + db_dml do_update { + UPDATE acs_objects + SET title = :title, last_modified = now(), modifying_user = :user_id, modifying_ip = :peeraddr + WHERE object_id = :clipboard_id and object_type = 'cop_clipboard' + } +} -after_submit { + if {![empty_string_p $object_id]} { + ad_returnredirect "attach?[export_vars -url {object_id clipboard_id}]" + } else { + ad_returnredirect ./ + } + ad_script_abort +} Index: openacs-4/contrib/packages/cop-ui/www/clipboards/attach.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/clipboards/attach.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/clipboards/attach.tcl 28 Mar 2004 21:17:10 -0000 1.1 @@ -0,0 +1,31 @@ +# /packages/cop-ui/www/clipboard/attach.tcl +ad_page_contract { + Attach an object to one of your clipboards + Requires registration. + + @author Jeff Davis davis@xarg.net + @creation-date 10/30/2003 + @cvs-id $Id: attach.tcl,v 1.1 2004/03/28 21:17:10 jeffd Exp $ +} { + object_id:integer,notnull + clipboard_id:integer,notnull +} + +set user_id [auth::require_login] + +if {$clipboard_id < 0} { + ad_returnredirect "ae?object_id=$object_id" + ad_script_abort +} + +# If we got clipboard_id 0 then we need to create a "General" clipboard +if {$clipboard_id == 0} { + set clipboard_id [cop::clipboard::new -title "General"] +} + +if {$clipboard_id > 0} { + cop::clipboard::attach -clipboard_id $clipboard_id -object_id $object_id -user_id $user_id +} + +# should redirect to the original object and preserve state... +ad_returnredirect [get_referrer] Index: openacs-4/contrib/packages/cop-ui/www/clipboards/delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/clipboards/delete.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/clipboards/delete.tcl 28 Mar 2004 21:17:10 -0000 1.1 @@ -0,0 +1,17 @@ +# /packages/cop-ui/www/clipboard/delete.tcl +ad_page_contract { + delete a clipboard. + + @author Jeff Davis + @creation-date 11/2/2003 + @cvs-id $Id: delete.tcl,v 1.1 2004/03/28 21:17:10 jeffd Exp $ +} { + clipboard_id:integer,notnull +} + + +permission::require_permission -object_id $clipboard_id -privilege delete + +cop::clipboard::delete -clipboard_id $clipboard_id + +ad_returnredirect ./ Index: openacs-4/contrib/packages/cop-ui/www/clipboards/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/clipboards/index.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/clipboards/index.adp 28 Mar 2004 21:17:10 -0000 1.1 @@ -0,0 +1,21 @@ + + Your clipboards + clipboards + + You need to log in or register to manage you clipboards. + + + + You do not currently have any clipboards. + + + + + Index: openacs-4/contrib/packages/cop-ui/www/clipboards/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/clipboards/index.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/clipboards/index.tcl 28 Mar 2004 21:17:10 -0000 1.1 @@ -0,0 +1,15 @@ +# /packages/cop-ui/www/clipboard/view.tcl +ad_page_contract { + Display all the clipboards for the logged in user + + @author Jeff Davis (davis@xarg.net) + @creation-date 11/12/2003 + @cvs-id $Id: index.tcl,v 1.1 2004/03/28 21:17:10 jeffd Exp $ +} {} + + +set user_id [auth::require_login] + +if {$user_id > 0} { + cop::clipboard::clipboards -count $user_id clipboards +} Index: openacs-4/contrib/packages/cop-ui/www/clipboards/remove.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/clipboards/remove.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/clipboards/remove.tcl 28 Mar 2004 21:17:10 -0000 1.1 @@ -0,0 +1,20 @@ +# /packages/cop-ui/www/clipboard/remove.tcl +ad_page_contract { + Detach an item from the clipboard. + + @author Jeff Davis davis@xarg.net + @creation-date 10/30/2003 + @cvs-id $Id: remove.tcl,v 1.1 2004/03/28 21:17:10 jeffd Exp $ +} { + object_id:integer,notnull + clipboard_id:integer,notnull +} + +set user_id [auth::require_login] + +if {$clipboard_id < 0} { + ad_returnredirect "ae?object_id=$object_id" + ad_script_abort +} + +cop::clipboard::remove -user_id $user_id -clipboard_id $clipboard_id -object_id $object_id Index: openacs-4/contrib/packages/cop-ui/www/clipboards/view.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/clipboards/view.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/clipboards/view.adp 28 Mar 2004 21:17:10 -0000 1.1 @@ -0,0 +1,21 @@ + + @title@ + @context@ + + + Clipboard @title@ (@items:rowcount@ items) owned by @owner_name@ [Edit] + +

Items in this clipboard:

+ +
+ +

There are no items in this clipboard.

+
+ + Index: openacs-4/contrib/packages/cop-ui/www/clipboards/view.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/clipboards/view.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/clipboards/view.tcl 28 Mar 2004 21:17:10 -0000 1.1 @@ -0,0 +1,38 @@ +# /packages/cop-ui/www/clipboard/view.tcl +ad_page_contract { + display a given clipboards contents. + + @author Jeff Davis (davis@xarg.net) + @creation-date 11/12/2003 + @cvs-id $Id: view.tcl,v 1.1 2004/03/28 21:17:10 jeffd Exp $ +} { + clipboard_id:integer,notnull +} + +set user_id [auth::refresh_login] + +# Check that the user is permissioned for this clipboard. +permission::require_permission -party_id $user_id -object_id $clipboard_id -privilege read + +if {![db_0or1row clipboard { + SELECT u.first_names || ' ' || u.last_name as owner_name, c.owner_id, o.title + FROM cop_clipboards c, acs_objects o, acs_users_all u + WHERE c.clipboard_id = :clipboard_id + and o.object_id = c.clipboard_id + and o.object_type = 'cop_clipboard' + and c.owner_id = u.user_id}] } { + ad_return_complaint 1 "Invalid clipboard id." + ad_script_abort +} + +set context [list [list ./ Clipboards] $title] + +db_multirow -extend {clipped} items get_items { + SELECT o.object_id, o.object_type, coalesce(o.title,'object '||o.object_id) as item_title, to_char(m.clipped_on,'YYYY-MM-DD HH24:MI:SS') as clipped_ansi + FROM cop_clipboard_object_map m, acs_objects o + WHERE clipboard_id = :clipboard_id + and o.object_id = m.object_id +} { + set clipped [util::age_pretty -timestamp_ansi $clipped_ansi -sysdate_ansi [clock_to_ansi [clock seconds]]] +} + Index: openacs-4/contrib/packages/cop-ui/www/ratings/delete.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/ratings/Attic/delete.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/ratings/delete.tcl 28 Mar 2004 21:17:11 -0000 1.1 @@ -0,0 +1,20 @@ +# /packages/cop-ui/www/clipboard/attach.tcl +ad_page_contract { + Delete a rating. + + @author Jeff Davis davis@xarg.net + @creation-date 10/30/2003 + @cvs-id $Id: delete.tcl,v 1.1 2004/03/28 21:17:11 jeffd Exp $ +} { + rating_id:multiple,integer,notnull +} + +set user_id [auth::require_login] + +db_list nuke " + SELECT cop_rating__delete(rating_id) + FROM cop_ratings + WHERE rating_id in ([join $rating_id ,]) + and acs_permission__permission_p(rating_id,:user_id,'write') = 't'" + +ad_returnredirect [get_referrer] \ No newline at end of file Index: openacs-4/contrib/packages/cop-ui/www/ratings/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/ratings/index.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/ratings/index.adp 28 Mar 2004 21:17:11 -0000 1.1 @@ -0,0 +1,5 @@ + + @title@ + @context@ + + Index: openacs-4/contrib/packages/cop-ui/www/ratings/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/ratings/index.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/ratings/index.tcl 28 Mar 2004 21:17:11 -0000 1.1 @@ -0,0 +1,74 @@ +# /packages/cop-ui/www/clipboard/view.tcl +ad_page_contract { + Display the agg ratings. + + @author Jeff Davis (davis@xarg.net) + @creation-date 11/12/2003 + + @cvs-id $Id: index.tcl,v 1.1 2004/03/28 21:17:11 jeffd Exp $ +} { + {orderby "rating_img,desc"} +} + +set user_id [auth::refresh_login] + +set clause {} + +set title "All Ratings" + +set context [list ratings] + +set elements { + ratings { + label Ratings + display_template {@ratings.ratings@ (show)} + } + rating_img { + label "Average" + display_template {@ratings.rating_img;noquote@} + } + rated_on { + label "Last Rated" + } + object_title { + label {Item} + display_template {@ratings.object_title@} + } +} + +template::list::create \ + -name ratings \ + -multirow ratings \ + -elements $elements \ + -orderby { + ratings { + orderby_asc {ratings desc} + orderby_desc {ratings asc} + } + rating_img { + orderby_asc {rating_ave desc} + orderby_desc {rating_ave asc} + } + rated_on { + orderby_asc {o.last_modified desc} + orderby_desc {o.last_modified asc} + } + object_title { + orderby lower(o.title) + } + } -filters { + object_id {} + owner_id {} + } + + +set icons [cop::rating::icon_base] +db_multirow -extend {rating_img object_ratings_url rating} ratings ratings " + SELECT r.rating_ave, to_char(r.rated_on,'YYYY-MM-DD HH24:MI') as rated_on, o.title as object_title, r.object_one, r.ratings, r.rating_sum, r.rating_ave + FROM cop_rating_aggregates r, acs_objects o + WHERE o.object_id = r.object_one + [template::list::orderby_clause -orderby -name "ratings"]" { + set rating [format %.1f [expr {(round(2.0*$rating_ave))/2.0}]] + set rating_img "\"$rating\"" + set object_ratings_url "./ratings?object_id=$object_one" + } Index: openacs-4/contrib/packages/cop-ui/www/ratings/rate.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/ratings/Attic/rate.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/ratings/rate.tcl 28 Mar 2004 21:17:11 -0000 1.1 @@ -0,0 +1,23 @@ +# /packages/cop-ui/www/clipboard/attach.tcl +ad_page_contract { + Save a rating provided by a user. + + @author Jeff Davis davis@xarg.net + @creation-date 10/30/2003 + @cvs-id $Id: rate.tcl,v 1.1 2004/03/28 21:17:11 jeffd Exp $ +} { + object_one:integer,notnull + {object_two:integer {}} + dimension_key:notnull + rating:integer,notnull +} + +set user_id [auth::require_login] + +cop::rating::rate -dimension_key $dimension_key \ + -object_one $object_one \ + -object_two $object_two \ + -user_id $user_id \ + -rating $rating + +ad_returnredirect [get_referrer] Index: openacs-4/contrib/packages/cop-ui/www/ratings/ratings.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/ratings/ratings.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/ratings/ratings.adp 28 Mar 2004 21:17:11 -0000 1.1 @@ -0,0 +1,5 @@ + + @title@ + @context@ + + \ No newline at end of file Index: openacs-4/contrib/packages/cop-ui/www/ratings/ratings.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/ratings/ratings.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/ratings/ratings.tcl 28 Mar 2004 21:17:11 -0000 1.1 @@ -0,0 +1,123 @@ +# /packages/cop-ui/www/clipboard/view.tcl +ad_page_contract { + Display the ratings for object obj_id. + + @author Jeff Davis (davis@xarg.net) + @creation-date 11/12/2003 + + @cvs-id $Id: ratings.tcl,v 1.1 2004/03/28 21:17:11 jeffd Exp $ +} { + {object_id:integer {}} + {owner_id:integer {}} + {orderby "rating_img,desc"} +} + +set user_id [auth::refresh_login] +set admin_p [permission::permission_p -object_id [ad_conn package_id] -privilege admin] + +set clause {} +set title "Rating" +if {![empty_string_p $object_id]} { + set object_name [db_string object_name {select acs_object__name(:object_id);}] + append title " for $object_name" + append clause "and r.object_one = :object_id\n" +} + +if {![empty_string_p $owner_id]} { + set owner_name [db_string owner_name {select person__name(:owner_id);}] + append title " by $owner_name" + append clause "and r.owner_id = :owner_id\n" +} + +if {[empty_string_p "$owner_id$object_id"]} { + ad_return_complaint 1 [list "No object or person given"] +} + +set context [list [list ./ ratings] one] + +set elements { + rating_img { + label "Rating" + display_template "@ratings.rating_img;noquote@" + } +} + +if {[empty_string_p $owner_id]} { + lappend elements name { + label {[_ acs-subsite.Name]} + display_template {@ratings.name@ (ratings)} + } +} + +lappend elements rated { + label "Rated" + display_template {@ratings.rated;noquote@} +} + +if {[empty_string_p $object_id]} { + lappend elements object_title { + label {Item} + display_template {@ratings.object_title@ (ratings)} + } +} + + lappend elements extra { + label {Debug} + display_template {o.title:@ratings.obj_title@ url:@ratings.url_one@ type:@ratings.object_type@} + } + +if {$admin_p} { + set bulk [list "Delete ratings" delete] +} else { + set bulk {} +} + +template::list::create \ + -name ratings \ + -multirow ratings \ + -key rating_id \ + -elements $elements \ + -orderby { + name { + orderby_asc "lower(u.last_name),lower(u.first_names)" + orderby_desc "lower(u.last_name) desc,lower(u.first_names) desc" + } + rating_img { + orderby_desc {rating asc, o.last_modified desc} + orderby_asc {rating desc, o.last_modified desc} + } + rated { + orderby_desc {o.last_modified asc} + orderby_asc {o.last_modified desc} + } + object_title { + orderby lower(o.title) + } + } -filters { + object_id {} + owner_id {} + } -bulk_actions $bulk + +set icons [cop::rating::icon_base] +set now [clock_to_ansi [clock seconds]] +db_multirow -extend {rated rating_img user_url user_ratings_url object_ratings_url url_one} ratings ratings " + SELECT r.rating_id, u.first_names || ' ' || u.last_name as name, u.user_id, u.email, r.owner_id, r.rating, to_char(o.last_modified,'YYYY-MM-DD HH24:MI:SS') as rated_on, acs_object__name(o2.object_id) as object_title, r.object_one, o2.title as obj_title, o2.object_type + FROM acs_users_all u, cop_ratings r, acs_objects o, acs_objects o2 + WHERE r.owner_id = u.user_id + $clause + and o.object_id = r.rating_id + and o2.object_id = r.object_one + [template::list::orderby_clause -orderby -name "ratings"]" { + set rating [format %.1f $rating] + set rating_img "\"$rating\"" + set user_url [acs_community_member_url -user_id $user_id] + set user_ratings_url "ratings?owner_id=$user_id" + set object_ratings_url "ratings?object_id=$object_one" + set rated [regsub -all { } [util::age_pretty -timestamp_ansi $rated_on -sysdate_ansi $now] {\ }] + + if {[catch {set url_one [acs_sc_call -error FtsContentProvider url [list $object_one] $object_type]} errMsg]} { + global errorCode + set url_one $errorCode + } + } + Index: openacs-4/contrib/packages/cop-ui/www/related/index.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/related/index.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/related/index.adp 28 Mar 2004 21:17:11 -0000 1.1 @@ -0,0 +1,5 @@ + + @title@ + @context@ + + Index: openacs-4/contrib/packages/cop-ui/www/related/index.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/related/index.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/related/index.tcl 28 Mar 2004 21:17:11 -0000 1.1 @@ -0,0 +1,60 @@ +# /packages/cop-ui/www/related/index.tcl +ad_page_contract { + Display the recently related items + + @author Jeff Davis (davis@xarg.net) + @creation-date 11/12/2003 + + @cvs-id $Id: index.tcl,v 1.1 2004/03/28 21:17:11 jeffd Exp $ +} { + {orderby "related_on,desc"} +} + +set user_id [auth::refresh_login] + + +set title "Related items" + +set context [list {related items}] + +set elements { + object_one_title { + label {Item1} + display_template {@related.object_one_title@} + } + object_two_title { + label {Item2} + display_template {@related.object_two_title@} + } + related_on { + label {Added} + } + name { + label {By} + } + extra { + label {debug} + } +} + +template::list::create \ + -name related \ + -multirow related \ + -elements $elements \ + -orderby { + object_one_title { orderby lower(o1.title) } + object_two_title { orderby lower(o2.title) } + related_on { orderby ro.creation_date } + name { orderby {lower(person__name(ro.creation_user))}} + } + +db_multirow -extend {extra} related related " + SELECT to_char(ro.creation_date,'YYYY-MM-DD HH24:MI') as related_on, coalesce(o1.title,'? '||o1.object_type||o1.object_id) as object_one_title, o2.title as object_two_title, person__name(ro.creation_user) as name + FROM cop_rels r, acs_objects o1, acs_objects o2, acs_rels ar, acs_objects ro + WHERE o1.object_id = ar.object_id_one + and o2.object_id = ar.object_id_two + and ar.rel_id = r.rel_id + and ro.object_id = r.rel_id + [template::list::orderby_clause -orderby -name "related"]" { + set extra foo + } Index: openacs-4/contrib/packages/cop-ui/www/related/relate.adp =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/related/relate.adp,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/related/relate.adp 28 Mar 2004 21:17:11 -0000 1.1 @@ -0,0 +1,5 @@ + + @title@ + @context@ + + Index: openacs-4/contrib/packages/cop-ui/www/related/relate.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/related/relate.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/related/relate.tcl 28 Mar 2004 21:17:11 -0000 1.1 @@ -0,0 +1,98 @@ +# /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/03/28 21:17:11 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 { + object_type { + label {Type} + } + object_title { + label {Item} + } + clipboard { + label {Clipboard} + } + clipped { + label {Clipped on} + } +} + +lappend elements extra { + label {Debug} +} + +set bulk [list "Relate" relation-add] + + +template::list::create \ + -name relate \ + -multirow relate \ + -key object_id \ + -elements $elements \ + -orderby { + object_type {} + 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 + +db_multirow -extend extra relate relate " + SELECT * FROM ( + SELECT o.object_type,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') as clipped + FROM acs_objects o, cop_clipboards c, acs_objects co, cop_clipboard_object_map cm + 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 + UNION + SELECT o.object_type, 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') + FROM cop_object_views v, acs_objects o + WHERE o.object_id = v.object_id + and v.viewer_id = :user_id + and v.object_id != :object_one) 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 extra {} + } + + Index: openacs-4/contrib/packages/cop-ui/www/related/relation-add.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/related/Attic/relation-add.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/contrib/packages/cop-ui/www/related/relation-add.tcl 28 Mar 2004 21:17:11 -0000 1.1 @@ -0,0 +1,27 @@ +# /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/03/28 21:17:11 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 Index: openacs-4/contrib/packages/cop-ui/www/resources/big/s-0.5.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/resources/big/s-0.5.gif,v diff -u Binary files differ Index: openacs-4/contrib/packages/cop-ui/www/resources/big/s-1.0.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/resources/big/s-1.0.gif,v diff -u Binary files differ Index: openacs-4/contrib/packages/cop-ui/www/resources/big/s-1.5.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/resources/big/s-1.5.gif,v diff -u Binary files differ Index: openacs-4/contrib/packages/cop-ui/www/resources/big/s-2.0.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/resources/big/s-2.0.gif,v diff -u Binary files differ Index: openacs-4/contrib/packages/cop-ui/www/resources/big/s-2.5.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/resources/big/s-2.5.gif,v diff -u Binary files differ Index: openacs-4/contrib/packages/cop-ui/www/resources/big/s-3.0.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/resources/big/s-3.0.gif,v diff -u Binary files differ Index: openacs-4/contrib/packages/cop-ui/www/resources/big/s-3.5.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/resources/big/s-3.5.gif,v diff -u Binary files differ Index: openacs-4/contrib/packages/cop-ui/www/resources/big/s-4.0.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/resources/big/s-4.0.gif,v diff -u Binary files differ Index: openacs-4/contrib/packages/cop-ui/www/resources/big/s-4.5.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/resources/big/s-4.5.gif,v diff -u Binary files differ Index: openacs-4/contrib/packages/cop-ui/www/resources/big/s-5.0.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/resources/big/s-5.0.gif,v diff -u Binary files differ Index: openacs-4/contrib/packages/cop-ui/www/resources/small/s-0.5.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/resources/small/s-0.5.gif,v diff -u Binary files differ Index: openacs-4/contrib/packages/cop-ui/www/resources/small/s-1.0.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/resources/small/s-1.0.gif,v diff -u Binary files differ Index: openacs-4/contrib/packages/cop-ui/www/resources/small/s-1.5.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/resources/small/s-1.5.gif,v diff -u Binary files differ Index: openacs-4/contrib/packages/cop-ui/www/resources/small/s-2.0.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/resources/small/s-2.0.gif,v diff -u Binary files differ Index: openacs-4/contrib/packages/cop-ui/www/resources/small/s-2.5.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/resources/small/s-2.5.gif,v diff -u Binary files differ Index: openacs-4/contrib/packages/cop-ui/www/resources/small/s-3.0.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/resources/small/s-3.0.gif,v diff -u Binary files differ Index: openacs-4/contrib/packages/cop-ui/www/resources/small/s-3.5.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/resources/small/s-3.5.gif,v diff -u Binary files differ Index: openacs-4/contrib/packages/cop-ui/www/resources/small/s-4.0.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/resources/small/s-4.0.gif,v diff -u Binary files differ Index: openacs-4/contrib/packages/cop-ui/www/resources/small/s-4.5.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/resources/small/s-4.5.gif,v diff -u Binary files differ Index: openacs-4/contrib/packages/cop-ui/www/resources/small/s-5.0.gif =================================================================== RCS file: /usr/local/cvsroot/openacs-4/contrib/packages/cop-ui/www/resources/small/s-5.0.gif,v diff -u Binary files differ