Index: openacs-4/packages/xowiki/tcl/notification-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/xowiki/tcl/notification-procs.tcl,v diff -u -N -r1.23.2.3 -r1.23.2.4 --- openacs-4/packages/xowiki/tcl/notification-procs.tcl 8 Aug 2020 08:08:20 -0000 1.23.2.3 +++ openacs-4/packages/xowiki/tcl/notification-procs.tcl 26 Aug 2020 18:46:08 -0000 1.23.2.4 @@ -1,15 +1,14 @@ ::xo::library doc { XoWiki - Notification procs - + @creation-date 2006-08-08 @author Gustaf Neumann - @cvs-id $Id$ } namespace eval ::xowiki { - + ad_proc -private ::xowiki::notifications-install {} { - + set impl_id [acs_sc::impl::new_from_spec -spec { name xowiki_notif_type contract_name NotificationType @@ -19,54 +18,62 @@ ProcessReply xowiki::notification::process_reply } }] - + set type_id [notification::type::new \ -sc_impl_id $impl_id \ -short_name xowiki_notif \ -pretty_name "XoWiki Notification" \ -description "Notification of a new XoWiki page"] - + foreach delivery {email} { notification::type::delivery_method_enable -type_id $type_id \ - -delivery_method_id [notification::delivery::get_id -short_name $delivery] + -delivery_method_id [notification::delivery::get_id \ + -short_name $delivery] } - + foreach interval {instant hourly daily} { notification::type::interval_enable -type_id $type_id \ - -interval_id [notification::interval::get_id_from_name -name $interval] + -interval_id [notification::interval::get_id_from_name \ + -name $interval] } } - - + + ad_proc -private ::xowiki::notifications-uninstall {} { - + set type_id [notification::type::get_type_id -short_name xowiki_notif] - + foreach delivery {email} { notification::type::delivery_method_disable -type_id $type_id \ - -delivery_method_id [notification::delivery::get_id -short_name $delivery] + -delivery_method_id [notification::delivery::get_id \ + -short_name $delivery] } foreach interval {instant hourly daily} { notification::type::interval_disable -type_id $type_id \ - -interval_id [notification::interval::get_id_from_name -name $interval] + -interval_id [notification::interval::get_id_from_name \ + -name $interval] } - + notification::type::delete -short_name xowiki_notif - + acs_sc::impl::delete \ -contract_name "NotificationType" \ - -impl_name xowiki_notif_type + -impl_name xowiki_notif_type } } namespace eval ::xowiki::notification { ad_proc -private get_url {id} { - if {[::xo::dc 0or1row is_package_id {select 1 from apm_packages where package_id = :id}]} { + if {[::xo::dc 0or1row is_package_id { + select 1 from apm_packages where package_id = :id}] + } { # # the specified id is a package_id # - set node_id [::xo::dc get_value get_node_id {select node_id from site_nodes where object_id = :id}] + set node_id [::xo::dc get_value get_node_id { + select node_id from site_nodes where object_id = :id + }] set url [site_node::get_url -node_id $node_id] return $url } @@ -83,11 +90,11 @@ # id is a revision_id return [::xowiki::url $id] } - - + + ad_proc -public do_notifications { {-revision_id} - {-page} + {-page} {-html} {-text} {-new:boolean true} @@ -98,27 +105,28 @@ } { if {![info exists page]} { - set page [::xowiki::Package instantiate_page_from_id -revision_id $revision_id] + set page [::xowiki::Package instantiate_page_from_id \ + -revision_id $revision_id] $page volatile } else { set revision_id [$page set revision_id] } #ns_log notice "--n notification proc called for page [$page name] (revision_id $revision_id) in state [$page publish_status]" - + if {[$page set publish_status] eq "production"} { # # Don't do notification for pages under construction. # ns_log notice "--n xowiki::notification NO notification due to production state" return } - set pretty_link [$page pretty_link] + set pretty_link [$page pretty_link] $page absolute_links 1 if {![info exists html]} { set html [$page notification_render] } - + if {$html eq ""} { # # The notification renderer returned empty. Nothing to do. @@ -134,7 +142,7 @@ # pretty_link as base-url. # set html [ad_html_qualify_links -path [ad_file dirname $pretty_link] $html] - + if {![info exists text]} { set text [ad_html_text_convert -from text/html -to text/plain -- $html] } @@ -145,17 +153,22 @@ append text [dict get $details text] $page instvar package_id - set state [expr {[$page set last_modified] eq [$page set creation_date] ? "New" : "Updated"}] + set state [expr {[$page set last_modified] eq [$page set creation_date] + ? "New" : "Updated"}] set instance_name [::$package_id instance_name] - set notif_user_id [expr {[$page exists modifying_user] ? [$page set modifying_user] : [$page set creation_user]}] + set notif_user_id [expr {[$page exists modifying_user] + ? [$page set modifying_user] + : [$page set creation_user]}] #ns_log notice "--n per directory [$page set title] ($state)" notification::new \ -type_id [notification::type::get_type_id -short_name xowiki_notif] \ -object_id [$page set package_id] \ -response_id [$page set revision_id] \ - -notif_subject [$page notification_subject -instance_name $instance_name -state $state] \ + -notif_subject [$page notification_subject \ + -instance_name $instance_name \ + -state $state] \ -notif_text $text \ -notif_html $html \ -notif_user $notif_user_id @@ -166,7 +179,8 @@ set tree_id [category::get_tree $cat_id] array unset cat array unset label - foreach category_info [::xowiki::Category get_category_infos -tree_id $tree_id] { + foreach category_info [::xowiki::Category get_category_infos \ + -tree_id $tree_id] { lassign $category_info category_id category_label deprecated_p level set cat($level) $category_id set label($level) $category_label @@ -175,10 +189,14 @@ foreach level [array names cat] { #ns_log notice "--n category $cat($level) $label($level): [$page set title] ($state)" notification::new \ - -type_id [notification::type::get_type_id -short_name xowiki_notif] \ + -type_id [notification::type::get_type_id \ + -short_name xowiki_notif] \ -object_id $cat($level) \ -response_id [$page set revision_id] \ - -notif_subject [$page notification_subject -instance_name $instance_name -category_label $label($level) -state $state] \ + -notif_subject [$page notification_subject \ + -instance_name $instance_name \ + -category_label $label($level) \ + -state $state] \ -notif_text $text \ -notif_html $html \ -notif_user $notif_user_id @@ -189,18 +207,18 @@ ad_proc -private process_reply { reply_id} { Handles a reply to an xowiki notification. - + @author Deds Castillo (deds@i-manila.com.ph) @creation-date 2006-06-08 - + } { # DEDS: need to decide on what to do with this # do we publish it as comment? # for now, drop it return "f" - } + } } -::xo::library source_dependent +::xo::library source_dependent # # Local variables: