select name
Index: openacs-4/packages/contacts/tcl/contacts-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/contacts-procs.tcl,v
diff -u -r1.88 -r1.89
--- openacs-4/packages/contacts/tcl/contacts-procs.tcl 31 May 2006 17:13:29 -0000 1.88
+++ openacs-4/packages/contacts/tcl/contacts-procs.tcl 2 Jun 2006 09:18:31 -0000 1.89
@@ -81,7 +81,7 @@
}
}
-ad_proc -private contacts::create_revisions_sweeper {
+ad_proc -private contacts::sweeper {
} {
So that contacts searches work correctly, and quickly
every person or organization in the system
@@ -93,16 +93,17 @@
associated item_id and live_revisions.
} {
db_foreach get_persons_without_items {} {
- ns_log notice "contacts::create_revisions_sweeper creating content_item and content_revision for party_id: $person_id"
+ ns_log notice "contacts::sweeper creating content_item and content_revision for party_id: $person_id"
contact::revision::new -party_id $person_id
}
db_foreach get_organizations_without_items {} {
- ns_log notice "contacts::create_revisions_sweeper creating content_item and content_revision for organization_id: $organization_id"
+ ns_log notice "contacts::sweeper creating content_item and content_revision for organization_id: $organization_id"
contact::revision::new -party_id $organization_id
}
if { ![info exists person_id] && ![info exists organization_id] } {
- ns_log notice "contacts::create_revisions_sweeper no person or organization objects exist that do not have associated content_items"
+ ns_log notice "contacts::sweeper no person or organization objects exist that do not have associated content_items"
}
+ db_dml insert_privacy_records {}
}
ad_proc -public contacts::multirow {
@@ -203,6 +204,69 @@
return [db_0or1row rel_type_enabled_p {}]
}
+ad_proc -public contact::privacy_allows_p {
+ {-party_id:required}
+ {-type:required}
+ {-package_id ""}
+} {
+ @param party_id the party_id to check permission for
+ @param type either 'email', 'mail' or 'phone'
+ @returns 1 or 0 if the specified type of communication is allowed
+} {
+ if { [parameter::get -boolean -package_id $package_id -parameter "ContactPrivacyEnabledP" -default "0"] } {
+ if { $package_id eq "" } {
+ if { [ad_conn package_key] eq "contacts" } {
+ set package_id [ad_conn package_id]
+ } else {
+ error "You must specify a valid contacts package id if your are accessing this procedure from a package other than contacts"
+ }
+ }
+ if { [lsearch [list email mail phone] $type] < 0 } {
+ error "contact::privacy_allows_p, you specified an invalid type: '${type}' (you must specify, email, mail or phone)"
+ }
+ if { [db_string is_type_allowed_p {} -default {1}] } {
+ return 1
+ } else {
+ return 0
+ }
+ }
+ # by default permission is allowed
+ return 1
+}
+
+ad_proc -public contact::privacy_prevents_p {
+ {-party_id:required}
+ {-type:required}
+ {-package_id ""}
+} {
+ @param party_id the party_id to check permission for
+ @param type either 'email', 'mail' or 'phone'
+ @returns 1 or 0 if the specified type of communication is allowed
+} {
+ if { [contact::privacy_allows_p -party_id $party_id -type $type -package_id $package_id] } {
+ return 0
+ } else {
+ return 1
+ }
+}
+
+ad_proc -public contact::privacy_set {
+ {-party_id:required}
+ {-email_p:required}
+ {-mail_p:required}
+ {-phone_p:required}
+ {-gone_p:required}
+} {
+} {
+ db_transaction {
+ if { [db_0or1row record_exists_p {}] } {
+ db_dml update_privacy {}
+ } else {
+ db_dml insert_privacy {}
+ }
+ }
+}
+
ad_proc -private contact::util::generate_filename {
{-title:required}
{-extension:required}
Index: openacs-4/packages/contacts/www/contact-add.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/contact-add.tcl,v
diff -u -r1.48 -r1.49
--- openacs-4/packages/contacts/www/contact-add.tcl 21 May 2006 00:43:42 -0000 1.48
+++ openacs-4/packages/contacts/www/contact-add.tcl 2 Jun 2006 09:18:31 -0000 1.49
@@ -100,6 +100,26 @@
-object_type $object_type \
-list_names $list_names]
+
+if { [parameter::get -boolean -package_id $package_id -parameter "ContactPrivacyEnabledP" -default "0"] } {
+ set privacy_setting_options [list]
+ if { $object_type eq "organization" } {
+ lappend privacy_setting_options [list [_ contacts.This_organization_has_closed_down] gone_p]
+ } else {
+ lappend privacy_setting_options [list [_ contacts.This_person_is_deceased] gone_p]
+ }
+ lappend privacy_setting_options [list [_ contacts.Do_not_email] email_p]
+ lappend privacy_setting_options [list [_ contacts.Do_not_mail] mail_p]
+ lappend privacy_setting_options [list [_ contacts.Do_not_phone] phone_p]
+
+ lappend form_definition [list contact_privacy_settings:boolean(checkbox),multiple,optional \
+ [list label [_ contacts.Privacy_Settings]] \
+ [list options $privacy_setting_options] \
+ ]
+}
+
+
+
#ad_return_error "$object_type" "$list_names :: $form_definition"
# Creating the form
@@ -323,6 +343,35 @@
set object_type [_ contacts.$object_type]
util_user_message -html -message "[_ contacts.lt_The_-object_type-_-contact_link-_was_added]"
+ if { [parameter::get -boolean -package_id $package_id -parameter "ContactPrivacyEnabledP" -default "0"] } {
+ set contact_privacy_settings [template::element::get_values party_ae contact_privacy_settings]
+ set gone_p 0
+ set email_p 1
+ set mail_p 1
+ set phone_p 1
+ if { [lsearch $contact_privacy_settings gone_p] >= 0 } {
+ set gone_p 1
+ set email_p 0
+ set mail_p 0
+ set phone_p 0
+ } else {
+ if { [lsearch $contact_privacy_settings email_p] >= 0 } {
+ set email_p 0
+ }
+ if { [lsearch $contact_privacy_settings mail_p] >= 0 } {
+ set mail_p 0
+ }
+ if { [lsearch $contact_privacy_settings phone_p] >= 0 } {
+ set phone_p 0
+ }
+ }
+ contact::privacy_set \
+ -party_id $party_id \
+ -email_p $email_p \
+ -mail_p $mail_p \
+ -phone_p $phone_p \
+ -gone_p $gone_p
+ }
} -after_submit {
contact::flush -party_id $party_id
Index: openacs-4/packages/contacts/www/contact-edit.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/contact-edit.tcl,v
diff -u -r1.21 -r1.22
--- openacs-4/packages/contacts/www/contact-edit.tcl 28 May 2006 01:30:28 -0000 1.21
+++ openacs-4/packages/contacts/www/contact-edit.tcl 2 Jun 2006 09:18:31 -0000 1.22
@@ -42,6 +42,24 @@
append form_elements " [ams::ad_form::elements -package_key "contacts" -object_type $object_type -list_names $ams_forms]"
+
+if { [parameter::get -boolean -package_id $package_id -parameter "ContactPrivacyEnabledP" -default "0"] } {
+ set privacy_setting_options [list]
+ if { $object_type eq "organization" } {
+ lappend privacy_setting_options [list [_ contacts.This_organization_has_closed_down] gone_p]
+ } else {
+ lappend privacy_setting_options [list [_ contacts.This_person_is_deceased] gone_p]
+ }
+ lappend privacy_setting_options [list [_ contacts.Do_not_email] email_p]
+ lappend privacy_setting_options [list [_ contacts.Do_not_mail] mail_p]
+ lappend privacy_setting_options [list [_ contacts.Do_not_phone] phone_p]
+
+ lappend form_elements [list contact_privacy_settings:boolean(checkbox),multiple,optional \
+ [list label [_ contacts.Privacy_Settings]] \
+ [list options $privacy_setting_options] \
+ ]
+}
+
ad_form -name party_ae \
-mode "edit" \
-export {return_url} \
@@ -83,6 +101,13 @@
ad_return_error "[_ contacts.Configuration_Error]" "[_ contacts.lt_Some_of_the_required__1]- [join $missing_elements "
- "]
"
}
+ if { [db_0or1row select_privacy_settings { select * from contact_privacy where party_id = :party_id }] } {
+ set contact_privacy_settings [list]
+ if { [string is false $email_p] } { lappend contact_privacy_settings email_p }
+ if { [string is false $mail_p] } { lappend contact_privacy_settings mail_p }
+ if { [string is false $phone_p] } { lappend contact_privacy_settings phone_p }
+ if { [string is true $gone_p] } { lappend contact_privacy_settings gone_p }
+ }
} -edit_request {
set revision_id [contact::live_revision -party_id $party_id]
foreach form $ams_forms {
@@ -188,6 +213,35 @@
} else {
callback contact::person_add -package_id $package_id -person_id $party_id
}
+ if { [parameter::get -boolean -package_id $package_id -parameter "ContactPrivacyEnabledP" -default "0"] } {
+ set contact_privacy_settings [template::element::get_values party_ae contact_privacy_settings]
+ set gone_p 0
+ set email_p 1
+ set mail_p 1
+ set phone_p 1
+ if { [lsearch $contact_privacy_settings gone_p] >= 0 } {
+ set gone_p 1
+ set email_p 0
+ set mail_p 0
+ set phone_p 0
+ } else {
+ if { [lsearch $contact_privacy_settings email_p] >= 0 } {
+ set email_p 0
+ }
+ if { [lsearch $contact_privacy_settings mail_p] >= 0 } {
+ set mail_p 0
+ }
+ if { [lsearch $contact_privacy_settings phone_p] >= 0 } {
+ set phone_p 0
+ }
+ }
+ contact::privacy_set \
+ -party_id $party_id \
+ -email_p $email_p \
+ -mail_p $mail_p \
+ -phone_p $phone_p \
+ -gone_p $gone_p
+ }
} -after_submit {
contact::flush -party_id $party_id
contact::search::flush_results_counts
Index: openacs-4/packages/contacts/www/contact.adp
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/www/contact.adp,v
diff -u -r1.42 -r1.43
--- openacs-4/packages/contacts/www/contact.adp 28 Apr 2006 10:15:08 -0000 1.42
+++ openacs-4/packages/contacts/www/contact.adp 2 Jun 2006 09:18:31 -0000 1.43
@@ -2,6 +2,7 @@
@party_id@