Index: openacs-4/packages/contacts/tcl/attribute-procs-postgresql.xql
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/attribute-procs-postgresql.xql,v
diff -u -r1.5 -r1.6
--- openacs-4/packages/contacts/tcl/attribute-procs-postgresql.xql 29 Aug 2005 22:49:50 -0000 1.5
+++ openacs-4/packages/contacts/tcl/attribute-procs-postgresql.xql 18 Dec 2005 18:18:57 -0000 1.6
@@ -84,7 +84,11 @@
- select * from postal_addresses where address_id = :address_id
+select ams_attribute_value__value(aa.attribute_id,value_id) as value
+ from ams_attribute_values aav, ams_attributes aa
+ where aav.object_id = :revision_id
+ and aa.attribute_id = aav.attribute_id
+ $where_clause
Index: openacs-4/packages/contacts/tcl/attribute-procs.tcl
===================================================================
RCS file: /usr/local/cvsroot/openacs-4/packages/contacts/tcl/attribute-procs.tcl,v
diff -u -r1.7 -r1.8
--- openacs-4/packages/contacts/tcl/attribute-procs.tcl 14 Nov 2005 20:03:54 -0000 1.7
+++ openacs-4/packages/contacts/tcl/attribute-procs.tcl 18 Dec 2005 18:18:58 -0000 1.8
@@ -114,14 +114,32 @@
}
ad_proc -public get {
- {-address_id:required}
+ {-attribute_id}
+ {-attribute_name ""}
+ {-party_id:required}
{-array:required}
} {
get the info from addresses
} {
upvar $array row
-
- db_1row select_address_info {} -column_array row
+ if {[exists_and_not_null attribute_id]} {
+ set where_clause "and aa.attribute_id = :attribute_id"
+ } else {
+ set where_clause "and aa.attribute_name = :attribute_name"
+ }
+ set revision_id [contact::live_revision -party_id $party_id]
+ set value [db_string select_address_info {} -default ""]
+ if {[string eq "" $value]} {
+ return 0
+ } else {
+ set mailing_address_list [ams::widget \
+ -widget postal_address \
+ -request "value_list" \
+ -value $value \
+ ]
+ template::util::list_of_lists_to_array $mailing_address_list row
+ return 1
+ }
}
}
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.45 -r1.46
--- openacs-4/packages/contacts/tcl/contacts-procs.tcl 18 Dec 2005 12:29:27 -0000 1.45
+++ openacs-4/packages/contacts/tcl/contacts-procs.tcl 18 Dec 2005 18:18:58 -0000 1.46
@@ -174,7 +174,7 @@
ad_proc -public contact::employee::get {
{-employee_id:required}
{-array:required}
- {-organization_id}
+ {-organization_id ""}
} {
Get full employee information. If employee does not have a phone number, fax number, or an e-mail address, the employee will be assigned the corresponding employer value, if an employer exists. Cached.
@@ -207,6 +207,19 @@
@param employee_id The ID of the employee whose information you wish to retrieve.
@param organization_id ID of the organization whose information should be returned if the employee_id is an employee at this organization. If not specified, defaults to first employer relationship found, if any.
@return Array-list of data.
+ @return first_names First Name of the person
+ @return last_name
+ @return salutation
+ @return person_title
+ @return direct_phoneno Direct phone number of the person, use company one if non existing
+ @return directfaxno Direct Fax number, use company one if non existing
+ @return email email of the person or the company (if there is no email for this person)
+ @return company_name name of the company (if there is an employing company)
+ @return address Street of the person (or company)
+ @return municipality
+ @return region
+ @return postal_code
+ @return country_code
} {
ns_log notice "start processing"
set employer_exist_p 0
@@ -243,22 +256,22 @@
set employee_id [content::item::get_best_revision -item_id $employee_id]
set employer_id [content::item::get_best_revision -item_id [lindex $employer 0]]
}
-
+
# Set the attributes
foreach attribute $employee_attributes {
set value [ams::value \
-object_id $employee_id \
-attribute_name $attribute
]
set local_array($attribute) $value
-
- set address_id [attribute::id -object_type "person" -attribute_name "home_address"]
- contacts::postal_address::get -address_id $address_id -array home_address_array
- set local_array(address) $home_address_array(delivery_address)
- set local_array(municipality) $home_address_array(municipality)
- set local_array(region) $home_address_array(region)
- set local_array(postal_code) $home_address_array(postal_code)
- set local_array(country_code) $home_address_array(country_code)
+
+ if {[contacts::postal_address::get -attribute_name "home_address" -party_id $employee_id -array home_address_array]} {
+ set local_array(address) $home_address_array(delivery_address)
+ set local_array(municipality) $home_address_array(municipality)
+ set local_array(region) $home_address_array(region)
+ set local_array(postal_code) $home_address_array(postal_code)
+ set local_array(country_code) $home_address_array(country_code)
+ }
}
if {$employer_exist_p} {
foreach attribute $employer_attributes {
@@ -282,13 +295,13 @@
}
if {![exists_and_not_null local_array(address)]} {
- set address_id [attribute::id -object_type "organization" -attribute_name "company_address"]
- contacts::postal_address::get -address_id $address_id -array address_array
- set local_array(address) $address_array(delivery_address)
- set local_array(municipality) $address_array(municipality)
- set local_array(region) $address_array(region)
- set local_array(postal_code) $address_array(postal_code)
- set local_array(country_code) $address_array(country_code)
+ if {[contacts::postal_address::get -attribute_name "company_address" -party_id [lindex $employer 0] -array address_array]} {
+ set local_array(address) $address_array(delivery_address)
+ set local_array(municipality) $address_array(municipality)
+ set local_array(region) $address_array(region)
+ set local_array(postal_code) $address_array(postal_code)
+ set local_array(country_code) $address_array(country_code)
+ }
}
}