xowiki::notification::do_notifications (public)

 xowiki::notification::do_notifications [ -revision_id revision_id ] \
    [ -page page ] [ -html html ] [ -text text ] [ -new ]

Defined in packages/xowiki/tcl/notification-procs.tcl

generate a notification

Switches:
-revision_id
(optional)
-page
(optional)
-html
(optional)
-text
(optional)
-new
(boolean) (defaults to "true") (optional)
new or modified item

Partial Call Graph (max 5 caller/called nodes):
%3 Class ::xowiki::WikiForm Class ::xowiki::WikiForm (public) xowiki::notification::do_notifications xowiki::notification::do_notifications Class ::xowiki::WikiForm->xowiki::notification::do_notifications ad_file ad_file (public) xowiki::notification::do_notifications->ad_file ad_html_qualify_links ad_html_qualify_links (public) xowiki::notification::do_notifications->ad_html_qualify_links ad_html_text_convert ad_html_text_convert (public) xowiki::notification::do_notifications->ad_html_text_convert category::get_mapped_categories category::get_mapped_categories (public) xowiki::notification::do_notifications->category::get_mapped_categories category::get_tree category::get_tree (public) xowiki::notification::do_notifications->category::get_tree

Testcases:
No testcase defined.
Source code:

    if {![info exists page]} {
      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]
    $page absolute_links 1
    if {![info exists html]} {
      set html [$page notification_render]
    }

    if {$html eq ""} {
      #
      # The notification renderer returned empty. Nothing to do.
      #
      #ns_log notice "--n notification renderer returned empty for page [$page name] (revision_id $revision_id). Nothing to do"
      return
    }

    #
    # Turn relative URLs into absolute URLs in the HTML text such that
    # links in notification still work. The function supports as well
    # non-wiki links. Here we are able to provide an accurate
    # 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]
    }

    #ns_log notice "--n xowiki do_notifications called for revision_id $revision_id publish_status=[$page set publish_status]"
    set details [$page notification_detail_link]
    append html [dict get $details html]
    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 instance_name [::$package_id instance_name]

    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_text $text  -notif_html $html  -notif_user $notif_user_id

    #ns_log notice "--n find categories [$page set title] ($state)"

    foreach cat_id [category::get_mapped_categories [$page set item_id] ] {
      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] {
        lassign $category_info category_id category_label deprecated_p level
        set cat($level$category_id
        set label($level$category_label
        if {$category_id == $cat_id} break
      }
      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]  -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_text $text  -notif_html $html  -notif_user $notif_user_id
      }
    }
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: