Index: openacs-4/packages/acs-subsite/tcl/party-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/Attic/party-procs.tcl,v diff -u -r1.2.14.2 -r1.2.14.3 --- openacs-4/packages/acs-subsite/tcl/party-procs.tcl 20 Feb 2006 07:36:05 -0000 1.2.14.2 +++ openacs-4/packages/acs-subsite/tcl/party-procs.tcl 13 May 2006 11:21:28 -0000 1.2.14.3 @@ -224,5 +224,51 @@ set email [db_string get_party_email { select email from parties where party_id = :party_id } -default {}] return $email } + + ad_proc -public name { + {-party_id ""} + {-email ""} + } { + Gets the party name of the provided party_id + + @author Miguel Marin (miguelmarin@viaro.net) + @author Viaro Networks www.viaro.net + + @author Malte Sussdorff (malte.sussdorff@cognovis.de) + + @param party_id The party_id to get the name from. + @param email The email of the party + + @returns The party name + } { + if {$party_id eq "" && $email eq ""} { + error "You need to provide either party_id or email" + } elseif {![string eq "" $party_id] && ![string eq "" $email]} { + error "Only provide provide party_id OR email, not both" + } + + if {$party_id eq ""} { + set party_id [party::get_by_email -email $email] + } + + if {[person::person_p -party_id $party_id]} { + set name [person::name -person_id $party_id] + } else { + if { [apm_package_installed_p "organizations"] } { + set name [db_string get_org_name {} -default ""] + } + + if { [empty_string_p $name] } { + set name [db_string get_group_name {} -default ""] + } + + if { [empty_string_p $name] } { + set name [db_string get_party_name {} -default ""] + } + + } + return $name + } + } Index: openacs-4/packages/acs-subsite/tcl/party-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-subsite/tcl/Attic/party-procs.xql,v diff -u -r1.2 -r1.2.14.1 --- openacs-4/packages/acs-subsite/tcl/party-procs.xql 15 May 2001 16:59:00 -0000 1.2 +++ openacs-4/packages/acs-subsite/tcl/party-procs.xql 13 May 2006 11:21:28 -0000 1.2.14.1 @@ -11,5 +11,37 @@ + + + select + name + from + organizations + where + organization_id = :party_id + + + + + + select + group_name + from + groups + where + group_id = :party_id + + + + + + select + party_name + from + party_names + where + party_id = :party_id + + Index: openacs-4/packages/acs-tcl/tcl/community-core-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/community-core-procs.tcl,v diff -u -r1.47.2.3 -r1.47.2.4 --- openacs-4/packages/acs-tcl/tcl/community-core-procs.tcl 27 Jan 2006 16:53:26 -0000 1.47.2.3 +++ openacs-4/packages/acs-tcl/tcl/community-core-procs.tcl 13 May 2006 11:21:27 -0000 1.47.2.4 @@ -199,11 +199,18 @@ } ad_proc -public person::name { - {-person_id:required} + {-person_id ""} + {-email ""} } { get the name of a person. Cached. } { - return [util_memoize [list person::name_not_cached -person_id $person_id]] + if {$person_id eq "" && $email eq ""} { + error "You need to provide either person_id or email" + } elseif {![string eq "" $person_id] && ![string eq "" $email]} { + error "Only provide provide person_id OR email, not both" + } else { + return [util_memoize [list person::name_not_cached -person_id $person_id -email $email]] + } } ad_proc -public person::name_flush { @@ -216,11 +223,18 @@ } ad_proc -public person::name_not_cached { - {-person_id:required} + {-person_id ""} + {-email ""} } { get the name of a person } { - db_1row get_person_name {} + if {$email eq ""} { + db_1row get_person_name {} + } else { + # As the old functionality returned an error, but I want an empty string for e-mail + # Therefore for emails we use db_string + set person_name [db_string get_person_name {} -default ""] + } return $person_name } @@ -656,7 +670,13 @@ @return party_id } { - return [db_string select_party_id {*SQL*} -default ""] + # return [db_string select_party_id {*SQL*} -default ""] + + # The following query is identical in the result as the one above + # It just takes into account that some applications (like contacts) make email not unique + # Instead of overwriting this procedure in those packages, I changed it here, as the functionality + # is unchanged. + return [lindex [db_list select_party_id {}] 0] } ad_proc -public party::approved_members { Index: openacs-4/packages/acs-tcl/tcl/community-core-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-tcl/tcl/community-core-procs.xql,v diff -u -r1.16.2.2 -r1.16.2.3 --- openacs-4/packages/acs-tcl/tcl/community-core-procs.xql 27 Jan 2006 16:53:26 -0000 1.16.2.2 +++ openacs-4/packages/acs-tcl/tcl/community-core-procs.xql 13 May 2006 11:21:27 -0000 1.16.2.3 @@ -69,9 +69,10 @@ - select first_names||' '||last_name as person_name - from persons - where person_id = :person_id + select distinct first_names||' '||last_name as person_name + from persons, parties + where person_id = party_id + and (party_id = :person_id or email = :email)