acs_mail_lite::get_address_array (private)

 acs_mail_lite::get_address_array -addresses addresses

Defined in packages/acs-mail-lite/tcl/acs-mail-lite-procs.tcl

Checks if passed variable is already an array of emails, user_names and user_ids. If not, get the additional data from the db and return the full array.

Switches:
-addresses (required)
Options:
-addresses
variable to checked for array
Returns:
array of emails, user_names and user_ids to be used for the mail procedures

Partial Call Graph (max 5 caller/called nodes):
%3 acs_mail_lite::parse_email_address acs_mail_lite::parse_email_address (private) db_0or1row db_0or1row (public) acs_mail_lite::get_address_array acs_mail_lite::get_address_array acs_mail_lite::get_address_array->acs_mail_lite::parse_email_address acs_mail_lite::get_address_array->db_0or1row

Testcases:
No testcase defined.
Source code:
        if {[catch {array set address_array $addresses}]
            || [lsort [array names address_array]] ne [list email name user_id]
        } {
            #
            # Either user just passed a normal address-list or
            # user passed an array, but forgot to provide user_ids
            # or user_names, so we have to get this data from the db
            #
            if {![info exists address_array(email)]} {
                # so user passed on a normal address-list
                set address_array(email) $addresses
            }

            set address_list [list]
            foreach email $address_array(email) {
                # strip out only the emails from address-list
                lappend address_list [string tolower [parse_email_address -email $email]]
            }

            array unset address_array
            # now get the user_names and user_ids
            foreach email $address_list {
                set email [string tolower $email]
                if {[db_0or1row get_user_name_and_id {
                    select person_id as user_id, first_names || ' ' || last_name as user_name
                    from parties, persons
                    where email = :email
                      and party_id = person_id
                     order by party_id desc
                    fetch first 1 rows only
                }]} {
                    lappend address_array(email) $email
                    lappend address_array(name) $user_name
                    lappend address_array(user_id) $user_id
                } else {
                    lappend address_array(email) $email
                    lappend address_array(name) ""
                    lappend address_array(user_id) ""
                }
            }
        }
        return [array get address_array]
Generic XQL file:
packages/acs-mail-lite/tcl/acs-mail-lite-procs.xql

PostgreSQL XQL file:
packages/acs-mail-lite/tcl/acs-mail-lite-procs-postgresql.xql

Oracle XQL file:
packages/acs-mail-lite/tcl/acs-mail-lite-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: