Index: openacs-4/packages/forums/tcl/forums-callback-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/forums/tcl/forums-callback-procs.tcl,v diff -u -r1.2 -r1.3 --- openacs-4/packages/forums/tcl/forums-callback-procs.tcl 3 Jan 2006 14:18:04 -0000 1.2 +++ openacs-4/packages/forums/tcl/forums-callback-procs.tcl 28 Jan 2006 15:30:17 -0000 1.3 @@ -99,3 +99,91 @@ } } +ad_proc -public -callback search::datasource -impl forums_message {} { + + @author dave@thedesignexperience.org + @creation_date 2005-06-07 + + returns a datasource for the search package + this is the content that will be indexed by the full text + search engine. + + We expect message_id to be a root message of a thread only, + and return the text of all the messages below + +} { + set message_id $object_id + # If there is no connection than this proc is called from the + # search indexer. In that case we set the locale to the + # system-wide default locale, since locale is needed for some part + # of the message formatting. + if { ![ad_conn isconnected] } { + ad_conn -set locale [lang::system::site_wide_locale] + } + + forum::message::get -message_id $message_id -array message + + if { ![empty_string_p $message(parent_id)] } { + ns_log debug "forum::message::datasource was called with a message_id that has a parent - skipping: $message_id" + set empty(object_id) $message_id + set empty(title) "" + set empty(content) "" + set empty(keywords) "" + set empty(storage_type) "text" + set empty(mime) "text/plain" + return [array get empty] + } + set relevant_date $message(posting_date) + ns_log debig "DIRK1 -${message(posting_date)}-" + + set tree_sortkey $message(tree_sortkey) + set forum_id $message(forum_id) + set combined_content "" + set subjects [list] + lappend subjects $message(subject) + array set forum [forum::get -forum_id $message(forum_id) -array forum] + set package_id $forum(package_id) + db_foreach messages "" { + + # include the subject in the text if it is different from the thread's subject + set root_subject $message(subject) + regexp {^(?:Re: )+(.*)$} $subject match subject + + if { [string compare $subject $root_subject] != 0 } { + # different subject + append combined_content "$subject\n\n" + } + + append combined_content [ad_html_text_convert -from $format -to text/plain -- $content] + + # In case this text is not only used for indexing but also for display, beautify it + append combined_content "\n\n" + set relevant_date $message(posting_date) + ns_log debug "DIRK2 -${message(posting_date)}-" + } + + return [list object_id $message(message_id) \ + title $message(subject) \ + content $combined_content \ + relevant_date $relevant_date \ + community_id [db_null] \ + keywords {} \ + storage_type text \ + mime text/plain \ + package_id $package_id] +} + +ad_proc -public -callback search::url -impl forums_message {} { + + @author dave@thedesignexperience.org + @creation_date 2005-06-08 + + returns a url for a message to the search package + +} { + set message_id $object_id + forum::message::get -message_id $message_id -array message + set forum_id $message(forum_id) + + return "[ad_url][db_string select_forums_package_url {}]message-view?message_id=$message_id" +}