forum::message::get (public)

 forum::message::get -message_id message_id -array array

Defined in packages/forums/tcl/messages-procs.tcl

Get the fields for a message.

Switches:
-message_id (required)
-array (required)

Partial Call Graph (max 5 caller/called nodes):
%3 test_forum_count_test forum_count_test (test forums) forum::message::get forum::message::get test_forum_count_test->forum::message::get test_forum_message_new forum_message_new (test forums) test_forum_message_new->forum::message::get test_web_forums_message_and_reply web_forums_message_and_reply (test forums) test_web_forums_message_and_reply->forum::message::get acs_user::get acs_user::get (public) forum::message::get->acs_user::get db_0or1row db_0or1row (public) forum::message::get->db_0or1row forum::attachments_enabled_p forum::attachments_enabled_p (public) forum::message::get->forum::attachments_enabled_p lc_time_fmt lc_time_fmt (public) forum::message::get->lc_time_fmt lc_time_system_to_conn lc_time_system_to_conn (public) forum::message::get->lc_time_system_to_conn callback::search::datasource::impl::forums_message callback::search::datasource::impl::forums_message (private) callback::search::datasource::impl::forums_message->forum::message::get forum::message::datasource forum::message::datasource (private, deprecated) forum::message::datasource->forum::message::get forum::message::delete forum::message::delete (public) forum::message::delete->forum::message::get forum::message::do_notifications forum::message::do_notifications (public) forum::message::do_notifications->forum::message::get forum::message::url forum::message::url (private, deprecated) forum::message::url->forum::message::get

Testcases:
forum_message_new, forum_count_test, web_forums_message_and_reply
Source code:
    # Select the info into the upvar'ed Tcl Array
    upvar $array row

    # make sure array is empty
    array unset row

    set forum_id [::xo::dc list -prepare integer get_forum_id_from_message_id {
        select forum_id from forums_messages where message_id = :message_id
    }]
    set attachments_sql [expr {[ns_conn isconnected] && [forum::attachments_enabled_p -forum_id $forum_id] ? {
        (select count(*) from attachments
         where object_id = m.message_id) as n_attachments,
    } : ""}]

    set sql [subst -nocommands {
        with recursive message_hierarchy as (
           select 1 as level, message_id, parent_id
             from forums_messages
            where message_id = :message_id

           union all

           select h.level + 1, m.message_id, m.parent_id
             from forums_messages m,
                  message_hierarchy h
            where m.message_id = h.parent_id
       )
       select m.*,
              $attachments_sql
              root.level as tree_level,
              root.message_id as root_message_id,
              (select subject from forums_messages
                where message_id = root.message_id) as root_subject,
              to_char(m.posting_date, 'YYYY-MM-DD HH24:MI:SS') as posting_date_ansi,
              (select name from forums_forums
                where forum_id = m.forum_id) as forum_name
        from forums_messages m,
             (select level, message_id
              from message_hierarchy
              where parent_id is null) as root
       where m.message_id = :message_id
    }]
    if {[db_0or1row select_message $sql -column_array row]} {
        set user [acs_user::get -user_id $row(user_id)]
        set row(user_name)   [dict get $user name]
        set row(user_email)  [dict get $user email]
        set row(screen_name) [dict get $user screen_name]

        # Convert to user's date/time format
        set row(posting_date_ansi) [lc_time_system_to_conn $row(posting_date_ansi)]
        set row(posting_date_pretty) [lc_time_fmt $row(posting_date_ansi) "%x %X"]
    }
XQL Not present:
PostgreSQL, Oracle
Generic XQL file:
packages/forums/tcl/messages-procs.xql

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