Index: openacs-4/packages/contacts/www/message-action.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/message-action.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/contacts/www/message-action.tcl 30 Jun 2005 00:07:49 -0000 1.1
@@ -0,0 +1,90 @@
+ad_page_contract {
+ List and manage contacts.
+
+ @author Matthew Geddert openacs@geddert.com
+ @creation-date 2004-07-28
+ @cvs-id $Id: message-action.tcl,v 1.1 2005/06/30 00:07:49 matthewg Exp $
+} {
+ {item_id:integer}
+ {owner_id:integer ""}
+ {action}
+ {return_url ""}
+} -validate {
+ item_exists -requires {item_id} {
+ if { ![db_0or1row message_exists_p { select 1 from contact_messages where item_id = :item_id}] && ![exists_and_not_null message_type]} {
+ ad_complain [_ contacts.lt_The_message_id_specified_does_not_exist]
+ }
+ }
+ action_valid -requires {action} {
+ if { [lsearch [list move copy delete] $action] < 0 } {
+ ad_complain [_ contacts.The_action_specified_is_invalid]
+ } elseif { ![permission::permission_p -object_id [ad_conn package_id] -privilege "admin"] } {
+ set message_owner_id [db_string get_owner_id { select owner_id from contact_messages where item_id = :item_id}]
+ switch $action {
+ "move" {
+ ad_complain [_ contacts.You_do_not_have_permission_to_move_searches]
+ }
+ "copy" {
+ if { $owner_id != [ad_conn user_id] } {
+ ad_complain [_ contacts.You_cannot_copy_searches_to_somebody_other_than_yourself]
+ }
+ }
+ "delete" {
+ if { $message_owner_id != [ad_conn user_id] } {
+ ad_complain [_ contacts.You_cannot_delete_searches_that_do_not_belong_to_you]
+ }
+ }
+ }
+ }
+ }
+ owner_valid -requires {owner_id} {
+ if { [exists_and_not_null owner_id] } {
+ if { $owner_id == [ad_conn package_id] || ( [contact::exists_p -party_id $owner_id] && [contact::type -party_id $owner_id] == "person" ) } {
+ } else {
+ ad_complain [_ contacts.The_owner_id_specified_is_not_valid]
+ }
+ }
+ }
+}
+
+db_1row select_message_info {}
+set package_id [ad_conn package_id]
+
+
+switch $action {
+ "move" {
+ db_dml update_owner {}
+ util_user_message -html -message [_ contacts.The_message_-title-_was_made_public]
+ }
+ "copy" {
+ regsub -all "'" $title "''" sql_title
+ set similar_titles [db_list select_similar_titles {}]
+ set number 1
+ set orig_title $title
+ while { [lsearch $similar_titles $title] >= 0 } {
+ set title "$orig_title ($number)"
+ incr number
+ }
+ contact::message::save \
+ -item_id $new_item_id \
+ -owner_id $owner_id \
+ -message_type $message_type \
+ -title $title \
+ -description $description \
+ -content $content \
+ -content_format $content_format
+ util_user_message -html -message [_ contacts.The_message_-title-_was_copied_to_your_messages]
+ }
+ "delete" {
+ db_dml expire_message {}
+ util_user_message -html -message [_ contacts.The_message_-title-_was_deleted]
+
+ }
+}
+
+if { ![exists_and_not_null return_url] } {
+ set return_url [export_vars -base "messages" -url {owner_id}]
+}
+
+ad_returnredirect $return_url
+ad_script_abort
Index: openacs-4/packages/contacts/www/message-action.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/message-action.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/contacts/www/message-action.xql 30 Jun 2005 00:07:49 -0000 1.1
@@ -0,0 +1,45 @@
+
+
+
+
+
+ select title,
+ acs_object_id_seq.nextval as new_item_id,
+ owner_id as old_owner_id,
+ message_type,
+ title,
+ description,
+ content,
+ content_format
+ from contact_messages
+ where item_id = :item_id
+
+
+
+
+
+ update contact_message_items
+ set owner_id = :owner_id
+ where item_id = :item_id
+
+
+
+
+
+ select title
+ from contact_messages
+ where owner_id = :owner_id
+ and upper(title) like upper('${sql_title}%')
+
+
+
+
+
+ update cr_items
+ set publish_status = 'expired'
+ where item_id = :item_id
+
+
+
+
+
Index: openacs-4/packages/contacts/www/messages.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/messages.adp,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/contacts/www/messages.adp 30 Jun 2005 00:07:49 -0000 1.1
@@ -0,0 +1,13 @@
+
+
+
+
Index: openacs-4/packages/contacts/www/messages.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/messages.tcl,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/contacts/www/messages.tcl 30 Jun 2005 00:07:49 -0000 1.1
@@ -0,0 +1,88 @@
+ad_page_contract {
+ List and manage contacts.
+
+ @author Matthew Geddert openacs@geddert.com
+ @creation-date 2004-07-28
+ @cvs-id $Id: messages.tcl,v 1.1 2005/06/30 00:07:49 matthewg Exp $
+} {
+ orderby:optional
+ {owner_id:optional}
+ {message_type ""}
+} -validate {
+}
+
+set user_id [ad_conn user_id]
+set package_id [ad_conn package_id]
+if { ![exists_and_not_null owner_id] } {
+ set owner_id $user_id
+}
+set owner_options [db_list_of_lists select_owner_options {}]
+set owner_options [concat [list [list [_ contacts.Public_Messages] "${package_id}"]] $owner_options]
+
+set message_types [ams::util::localize_and_sort_list_of_lists \
+ -list [db_list_of_lists get_message_types { select pretty_name, message_type from contact_message_types}] \
+ ]
+
+set actions [list]
+foreach type $message_types {
+ lappend actions "[_ contacts.Add] [lindex $type 0]" [export_vars -base message-ae -url [list [list message_type [lindex $type 1]]]] "[_ contacts.Add] [lindex $type 0]"
+ set type_pretty_name([lindex $type 1]) [lindex $type 0]
+}
+
+template::list::create \
+ -name "messages" \
+ -multirow "messages" \
+ -row_pretty_plural "[_ contacts.messages]" \
+ -actions $actions \
+ -key item_id \
+ -elements {
+ type_pretty {
+ label {#contacts.Type#}
+ display_col type_pretty
+ }
+ title {
+ label {#contacts.Title#}
+ display_col title
+ link_url_eval $message_url
+ }
+ action {
+ label ""
+ display_template {
+ #contacts.Copy#
+
+ #contacts.Delete#
+
+
+ #contacts.Make_Public#
+
+ }
+ }
+ } -filters {
+ owner_id {
+ label "\#contacts.Owner\#"
+ values $owner_options
+ where_clause ""
+ default_value $user_id
+ }
+ } -orderby {
+ } -formats {
+ }
+
+
+set return_url [export_vars -base messages -url {owner_id}]
+set admin_p [permission::permission_p -object_id $package_id -privilege "admin"]
+
+db_multirow -extend {message_url make_public_url delete_url copy_url type_pretty} -unclobber messages select_messages {} {
+ set type_pretty $type_pretty_name($message_type)
+ if { $owner_id != $package_id && $admin_p } {
+ set make_public_url [export_vars -base message-action -url {item_id {owner_id $package_id} {action move} return_url}]
+ }
+ if { $owner_id == $user_id || $admin_p } {
+ set delete_url [export_vars -base message-action -url {item_id {action delete}}]
+ }
+ set message_url [export_vars -base "message-ae" -url {item_id}]
+ set copy_url [export_vars -base message-action -url {item_id {owner_id $user_id} {action copy} return_url}]
+
+}
+
+
Index: openacs-4/packages/contacts/www/messages.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/messages.xql,v
diff -u
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ openacs-4/packages/contacts/www/messages.xql 30 Jun 2005 00:07:49 -0000 1.1
@@ -0,0 +1,33 @@
+
+
+
+
+
+ select CASE WHEN owner_id = :user_id
+ THEN '\#contacts.My_Messages\#'
+ ELSE contact__name(owner_id) END,
+ owner_id
+ from ( select distinct owner_id
+ from contact_messages
+ where ( title is not null or owner_id = :user_id )
+ and owner_id in ( select party_id from parties )) distinct_owners
+ order by CASE WHEN owner_id = :user_id THEN '0000000000000000000' ELSE upper(contact__name(owner_id)) END
+
+
+
+
+
+ select item_id,
+ owner_id,
+ message_type,
+ title,
+ description,
+ content,
+ content_format
+ from contact_messages
+ where owner_id = :owner_id
+ order by message_type, upper(title)
+
+
+
+