q-and-a-procs.tcl

Faq Library - Reply Handling

Location:
packages/faq/tcl/q-and-a-procs.tcl
Created:
2004-04-02
Author:
Gerardo Morales

Procedures in this file

Detailed information

faq::notification_delivery::do_notification (private)

 faq::notification_delivery::do_notification question answer entry_id \
    faq_id user_id

Issues notifications for a FAQ

Parameters:
question
answer
entry_id
faq_id
user_id

Partial Call Graph (max 5 caller/called nodes):
%3 packages/faq/www/admin/q-and-a-add-edit.tcl packages/faq/ www/admin/q-and-a-add-edit.tcl faq::notification_delivery::do_notification faq::notification_delivery::do_notification packages/faq/www/admin/q-and-a-add-edit.tcl->faq::notification_delivery::do_notification ad_conn ad_conn (public) faq::notification_delivery::do_notification->ad_conn db_string db_string (public) faq::notification_delivery::do_notification->db_string faq::notification::get_url faq::notification::get_url (private) faq::notification_delivery::do_notification->faq::notification::get_url notification::new notification::new (public) faq::notification_delivery::do_notification->notification::new notification::type::get_type_id notification::type::get_type_id (public) faq::notification_delivery::do_notification->notification::type::get_type_id

Testcases:
No testcase defined.
[ hide source ]

Content File Source

ad_library {

    Faq Library - Reply Handling
    @creation-date 2004-04-02
    @author Gerardo Morales <gmorales@galileo.edu>
}


namespace eval faq::notification_delivery {

    d_proc -private do_notification {
        question
        answer
        entry_id
        faq_id
        user_id
    } {
        Issues notifications for a FAQ
    } {
        set faq_name [db_string select_faq_name {
            select faq_name from faqs
            where faq_id = :faq_id
        }]
        set name [person::name -person_id $user_id]
        set email [party::email -party_id $user_id]

        set faq_url [faq::notification::get_url $entry_id]

        set q_a_text [ns_reflow_text -- "Question: $question\nAnswer: $answer"]
        set text_version [subst {Faq: $faq_name\nAuthor: $name ($email)\n\n$q_a_text\n\n--To view the entire FAQ go to: $faq_url}]

        set new_content $text_version
        set package_id [ad_conn package_id]

        # Notifies the users that requested notification for the specific FAQ
        notification::new \
            -type_id [notification::type::get_type_id \
                          -short_name one_faq_qa_notif] \
            -object_id $faq_id \
            -response_id $entry_id \
            -notif_subject "New Q&A of $faq_name" \
            -notif_text $new_content

        # Notifies the users that requested notification for all FAQ's
        notification::new \
            -type_id [notification::type::get_type_id \
                          -short_name all_faq_qa_notif] \
            -object_id $package_id \
            -response_id $entry_id \
            -notif_subject "New Q&A of $faq_name" \
            -notif_text $new_content
    }
}

# Local variables:
#    mode: tcl
#    tcl-indent-level: 4
#    indent-tabs-mode: nil
# End: