Index: openacs-4/packages/contacts/sql/postgresql/contacts-drop.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/contacts-drop.sql,v diff -u -r1.4 -r1.5 --- openacs-4/packages/contacts/sql/postgresql/contacts-drop.sql 8 Aug 2005 21:53:12 -0000 1.4 +++ openacs-4/packages/contacts/sql/postgresql/contacts-drop.sql 8 Sep 2005 18:14:00 -0000 1.5 @@ -8,6 +8,7 @@ drop table contact_search_conditions; drop table contact_searches; +drop table contact_extend_options; select drop_package('contact_search'); select acs_object__delete(search_id) from contact_searches; select acs_object_type__drop_type('contact_search','t'); @@ -29,3 +30,5 @@ select drop_package('contact'); select drop_package('contact_rel'); select drop_package('contact_party_revision'); + +drop sequence contact_extend_search_seq; \ No newline at end of file Index: openacs-4/packages/contacts/sql/postgresql/contacts-messages-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/contacts-messages-create.sql,v diff -u -r1.3 -r1.4 --- openacs-4/packages/contacts/sql/postgresql/contacts-messages-create.sql 28 Jul 2005 13:41:50 -0000 1.3 +++ openacs-4/packages/contacts/sql/postgresql/contacts-messages-create.sql 8 Sep 2005 18:14:00 -0000 1.4 @@ -50,7 +50,8 @@ create table contact_message_log ( message_id integer - constraint contact_message_log_message_id_pk primary key, + constraint contact_message_log_message_id_pk primary key + constraint contact_message_log_message_id_fk references acs_objects(object_id), message_type varchar(20) constraint contact_message_log_message_type_fk references contact_message_types(message_type) constraint contact_message_log_message_type_nn not null, @@ -72,3 +73,16 @@ ); + +select acs_object_type__create_type ( + 'contact_message_log', -- content_type + 'Contacts Message Log', -- pretty_name + 'Contacts Messages Logs', -- pretty_plural + 'acs_object', -- supertype + 'contact_message_log', -- table_name + 'object_id', -- id_column + 'contact_messages_log', -- package_name + 'f', -- abstract_p + NULL, -- type_extension_table + NULL -- name_method +); Index: openacs-4/packages/contacts/sql/postgresql/contacts-search-create.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/contacts-search-create.sql,v diff -u -r1.5 -r1.6 --- openacs-4/packages/contacts/sql/postgresql/contacts-search-create.sql 14 Jun 2005 07:25:18 -0000 1.5 +++ openacs-4/packages/contacts/sql/postgresql/contacts-search-create.sql 8 Sep 2005 18:14:00 -0000 1.6 @@ -144,3 +144,17 @@ return ''1''; end;' language 'plpgsql'; + + +-- Create a sequence and a table for extended searches. + +create sequence contact_extend_search_seq; + +create table contact_extend_options ( + extend_id integer + constraint contact_extend_options_pk primary key, + var_name varchar(100) unique not null, + pretty_name varchar(100) not null, + subquery varchar(5000) not null, + description varchar(500) +); \ No newline at end of file Index: openacs-4/packages/contacts/sql/postgresql/upgrade/upgrade-1.0d8-1.0d9.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/upgrade/upgrade-1.0d8-1.0d9.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/sql/postgresql/upgrade/upgrade-1.0d8-1.0d9.sql 8 Sep 2005 18:14:00 -0000 1.1 @@ -0,0 +1,56 @@ +-- author Miguel Marin (miguelmarin@viaro.net) +-- author Viaro Networks www.viaro.net +-- Making all entries in contact_message_log an acs_object + +-- Creating the acs_object_type for contact_message_logs + +select acs_object_type__create_type ( + 'contact_message_log', -- content_type + 'Contacts Message Log', -- pretty_name + 'Contacts Messages Logs', -- pretty_plural + 'acs_object', -- supertype + 'contact_message_log', -- table_name + 'object_id', -- id_column + 'contact_messages_log', -- package_name + 'f', -- abstract_p + NULL, -- type_extension_table + NULL -- name_method +); + + +-- Making every message_id in contact_message_log an acs_objects + +create function inline_0() returns integer as ' +declare + v_row record; + v_object_id integer; +begin + + for v_row in select * from contact_message_log + loop + -- Since all entries in this table where created using acs_objects_seq.nextval + -- we just need to create an acs_object for that meessage_id + v_object_id := acs_object__new( + v_row.message_id, + ''contact_message_log'', + v_row.sent_date, + v_row.sender_id, + null, + null + ); + end loop; + return 0; + +end;' language 'plpgsql'; + +-- Calling and droping the function +select inline_0(); +drop function inline_0(); + + +-- Altering the table so every new message_id reference acs_objects object_id +alter table contact_message_log +add constraint contact_message_log_message_id_fk +foreign key (message_id) references acs_objects (object_id); + + Index: openacs-4/packages/contacts/sql/postgresql/upgrade/upgrade-1.0d9-1.0d10.sql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/sql/postgresql/upgrade/upgrade-1.0d9-1.0d10.sql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/sql/postgresql/upgrade/upgrade-1.0d9-1.0d10.sql 8 Sep 2005 18:14:00 -0000 1.1 @@ -0,0 +1,14 @@ +-- Author Miguel Marin (miguelmarin@viaro.net) +-- Author Viaro Networks www.viaro.net +-- Create a sequence and a table for extended searches. + +create sequence contact_extend_search_seq; + +create table contact_extend_options ( + extend_id integer + constraint contact_extend_options_pk primary key, + var_name varchar(100) unique not null, + pretty_name varchar(100) not null, + subquery varchar(5000) not null, + description varchar(500) +); \ No newline at end of file Index: openacs-4/packages/contacts/tcl/contact-extend-procs-postgresql.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-extend-procs-postgresql.xql,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/tcl/contact-extend-procs-postgresql.xql 8 Sep 2005 18:05:19 -0000 1.1 @@ -0,0 +1,65 @@ + + + + + + delete from + contact_extend_options + where + extend_id = :extend_id + + + + + + insert into contact_extend_options (extend_id,var_name,pretty_name,subquery,description) + values (:extend_id,:var_name,:pretty_name,:subquery,:description) + + + + + + update contact_extend_options + set var_name = :var_name, pretty_name = :pretty_name, subquery = :subquery, description = :description + where extend_id = :extend_id + + + + + + select + 1 + from + contact_extend_options + where + var_name = :var_name + + + + + + select + pretty_name, + extend_id + from + contact_extend_options + $extra_query + + + + + + select + var_name, + pretty_name, + subquery, + description + from + contact_extend_options + where + extend_id = :extend_id + + + + + Index: openacs-4/packages/contacts/tcl/contact-extend-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-extend-procs.tcl,v diff -u --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ openacs-4/packages/contacts/tcl/contact-extend-procs.tcl 8 Sep 2005 18:05:19 -0000 1.1 @@ -0,0 +1,77 @@ +ad_library { + + @author Miguel Marin (miguelmarin@viaro.net) + @author Viaro Networks www.viaro.net + @creation-date 2005-09-08 +} + +namespace eval contact::extend:: {} + +ad_proc -public contact::extend::delete { + -extend_id:required +} { + Deletes one contact extend option + @param extend_id The extend_id to delete +} { + db_dml extend_delete { } +} + +ad_proc -public contact::extend::new { + -extend_id:required + -var_name:required + -pretty_name:required + -subquery:required + {-description ""} +} { + Creates a new contact extend option +} { + set var_name [string tolower $var_name] + db_dml new_extend_option { } +} + + +ad_proc -public contact::extend::update { + -extend_id:required + -var_name:required + -pretty_name:required + -subquery:required + {-description ""} +} { + Updates one contact extend option +} { + set var_name [string tolower $var_name] + db_dml update_extend_option { } +} + +ad_proc -public contact::extend::var_name_check { + -var_name:required +} { + Checks if the name is already present on the contact_extend_options table or not +} { + set var_name [string tolower $var_name] + return [db_string check_name { } -default "0"] +} + +ad_proc -public contact::extend::get_options { + {-ignore_extends ""} +} { + Returns a list of the form { pretty_name extend_id } of all available extend options in + contact_extend_options + + @param ignore_extends A list of extend_id's to ignore on the result +} { + set extra_query "" + if { ![empty_string_p $ignore_extends] } { + set ignore_extends [join $ignore_extends ","] + append extra_query "where extend_id not in ($ignore_extends)" + } + return [db_list_of_lists get_options " "] +} + +ad_proc -public contact::extend::option_info { + -extend_id:required +} { + Returns a list of the form { var_name pretty_name subquery description } of the extend_id +} { + return [db_list_of_lists get_options { }] +} \ No newline at end of file Index: openacs-4/packages/contacts/tcl/contact-message-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contact-message-procs.tcl,v diff -u -r1.3 -r1.4 --- openacs-4/packages/contacts/tcl/contact-message-procs.tcl 2 Aug 2005 20:42:23 -0000 1.3 +++ openacs-4/packages/contacts/tcl/contact-message-procs.tcl 8 Sep 2005 18:05:19 -0000 1.4 @@ -105,11 +105,22 @@ if { ![exists_and_not_null sent_date] } { set sent_date [db_string get_current_timestamp { select now() }] } + set creation_ip [ad_conn peeraddr] + set package_id [ad_conn package_id] + # We make every message logged in this table an acs_object + set object_id [db_string create_acs_object { select acs_object__new ( + null, + 'contact_message_log', + :sent_date, + :sender_id, + :creation_ip, + :package_id + ) } ] db_dml log_message { insert into contact_message_log ( message_id, message_type, sender_id, recipient_id, sent_date, title, description, content, content_format) values - ( acs_object_id_seq.nextval, :message_type, :sender_id, :recipient_id, :sent_date, :title, :description, :content, :content_format) + ( :object_id, :message_type, :sender_id, :recipient_id, :sent_date, :title, :description, :content, :content_format) } }