• Publicity: Public Only All

notification-type-procs.tcl

Notification Types Notifications are categorized by type. These procs manage the types. Notification types are a service contract in order to handle notification replies appropriately (handling a forum reply is not the same as handling a calendar reply).

Location:
packages/notifications/tcl/notification-type-procs.tcl
Created:
2002-05-24
Author:
Ben Adida
CVS Identification:
$Id: notification-type-procs.tcl,v 1.16.2.7 2022/07/12 14:16:28 antoniop Exp $

Procedures in this file

Detailed information

notification::type::delete (public)

 notification::type::delete -short_name short_name

Remove a notification type. This is very rare.

Switches:
-short_name (required)

Testcases:
No testcase defined.

notification::type::delivery_method_disable (public)

 notification::type::delivery_method_disable -type_id type_id \
    -delivery_method_id delivery_method_id

Delivery methods must be enabled on a per notification type basis. For example, full forum posts may not be enabled for SMS delivery, as that would be too long. This disables a given delivery method for a given notification type.

Switches:
-type_id (required)
-delivery_method_id (required)

Testcases:
No testcase defined.

notification::type::delivery_method_enable (public)

 notification::type::delivery_method_enable -type_id type_id \
    -delivery_method_id delivery_method_id

Delivery methods must be enabled on a per notification type basis. For example, full forum posts may not be enabled for SMS delivery, as that would be too long. This enables a given delivery method for a given notification type.

Switches:
-type_id (required)
-delivery_method_id (required)

Testcases:
No testcase defined.

notification::type::get (public)

 notification::type::get -short_name short_name \
    -column_array column_array

select information about the notification type into the given Tcl Array

Switches:
-short_name (required)
-column_array (required)

Testcases:
No testcase defined.

notification::type::get_impl_key (public)

 notification::type::get_impl_key -type_id type_id

return the service contract implementation key for a given notification type.

Switches:
-type_id (required)

Testcases:
No testcase defined.

notification::type::get_type_id (public)

 notification::type::get_type_id -short_name short_name

return the notification type ID given a short name. Short names are unique but not primary keys.

Switches:
-short_name (required)

Testcases:
xowiki_test_cases

notification::type::interval_disable (public)

 notification::type::interval_disable -type_id type_id \
    -interval_id interval_id

Intervals must be enabled on a per notification type basis. For example, weekly notifications may not be enabled for full forum posts, as that might be too much email (system choice) This disables a given interval for a given notification type.

Switches:
-type_id (required)
-interval_id (required)

Testcases:
No testcase defined.

notification::type::interval_enable (public)

 notification::type::interval_enable -type_id type_id \
    -interval_id interval_id

Intervals must be enabled on a per notification type basis. For example, weekly notifications may not be enabled for full forum posts, as that might be too much email (system choice) This enables a given interval for a given notification type.

Switches:
-type_id (required)
-interval_id (required)

Testcases:
No testcase defined.

notification::type::new (public)

 notification::type::new [ -all_intervals ] [ -all_delivery_methods ] \
    [ -type_id type_id ] -sc_impl_id sc_impl_id -short_name short_name \
    -pretty_name pretty_name [ -description description ]

create a new notification type. Must provide a service contract implementation ID.

Switches:
-all_intervals (optional, boolean, defaults to "0")
-all_delivery_methods (optional, boolean, defaults to "0")
-type_id (optional)
-sc_impl_id (required)
-short_name (required)
-pretty_name (required)
-description (optional)

Testcases:
No testcase defined.

notification::type::process_reply (public)

 notification::type::process_reply -type_id type_id -reply_id reply_id

The wrapper procedure for processing a given reply. This calls down to the service contract implementation to specifically handle a reply.

Switches:
-type_id (required)
-reply_id (required)

Testcases:
No testcase defined.
[ hide source ] | [ make this the default ]

Content File Source

ad_library {

    Notification Types

    Notifications are categorized by type. These procs manage the types.
    Notification types are a service contract in order to handle notification replies appropriately
    (handling a forum reply is not the same as handling a calendar reply).

    @creation-date 2002-05-24
    @author Ben Adida <ben@openforce.biz>
    @cvs-id $Id: notification-type-procs.tcl,v 1.16.2.7 2022/07/12 14:16:28 antoniop Exp $

}

namespace eval notification::type {

    d_proc -public get_impl_key {
        {-type_id:required}
    } {
    return the service contract implementation key for a given notification type.
    } {
        return [db_string select_impl_key {}]
    }

    d_proc -public new {
        {-all_intervals:boolean 0}
        {-all_delivery_methods:boolean 0}
        {-type_id ""}
        {-sc_impl_id:required}
        {-short_name:required}
        {-pretty_name:required}
        {-description ""}
    } {
        create a new notification type. Must provide a service contract implementation ID.
    } {
        set extra_vars [ns_set create s \
                            type_id $type_id \
                            sc_impl_id $sc_impl_id \
                            short_name $short_name \
                            pretty_name $pretty_name \
                            description $description \
                           ]

        set type_id [package_instantiate_object -extra_vars $extra_vars notification_type]

        if { $all_intervals_p } {
            db_dml enable_all_intervals {}
        }

        if { $all_delivery_methods_p } {
            db_dml enable_all_delivery_methods {}
        }

        acs::per_thread_cache flush -pattern notifications.get_type_id($short_name)

        return $type_id
    }

    d_proc -public get_type_id {
        {-short_name:required}
    } {
    return the notification type ID given a short name.
        Short names are unique but not primary keys.
    } {
        return [acs::per_thread_cache eval -key notifications.get_type_id($short_name) {
            notification::type::get_type_id_not_cached $short_name
        }]
    }

    d_proc -private get_type_id_not_cached {
        short_name
    } {
    return the notification type ID given a short name. Short names are unique but not primary keys.
    } {
        return [db_string select_type_id {} -default {}]
    }

    d_proc -public delete {
        {-short_name:required}
    } {
    Remove a notification type. This is very rare.
    } {
        set type_id [notification::type::get_type_id_not_cached $short_name]

        db_exec_plsql delete_notification_type {}

        #
        # TODO: currently, the util_memoize_flush below does nothing
        # (we need in these rare cases a restart of the server to get
        # rid of the old cache entry - one can get still a
        # notification type id from the cache, although it is removed
        # from the db). The right thing would be a broadcast operation
        # for flushing (similar to xo*) or a blueprint epoch/refetch
        # (as under consideration for better live updates on the
        # OpenACS wish-list).
        #
        util_memoize_flush [list notification::type::get_type_id_not_cached $short_name]
    }

    d_proc -public get {
        {-short_name:required}
        {-column_array:required}
    } {
    select information about the notification type into the given Tcl Array
    } {
        # Select the data into the upvar'ed array
        upvar $column_array row
        db_1row select_notification_type {} -column_array row
    }

    d_proc -public interval_enable {
        {-type_id:required}
        {-interval_id:required}
    } {
    Intervals must be enabled on a per notification type basis. For example, weekly notifications
    may not be enabled for full forum posts, as that might be too much email (system choice)
    This enables a given interval for a given notification type.
    } {
        # Perform the insert if necessary
        db_dml insert_interval_map {}
    }

    d_proc -public interval_disable {
        {-type_id:required}
        {-interval_id:required}
    } {
    Intervals must be enabled on a per notification type basis. For example, weekly notifications
    may not be enabled for full forum posts, as that might be too much email (system choice)
    This disables a given interval for a given notification type.
    } {
        # perform the delete if necessary
        db_dml delete_interval_map {}
    }

    d_proc -public delivery_method_enable {
        {-type_id:required}
        {-delivery_method_id:required}
    } {
    Delivery methods must be enabled on a per notification type basis. For example, full forum posts
    may not be enabled for SMS delivery, as that would be too long.
    This enables a given delivery method for a given notification type.
    } {
        # perform the insert if necessary
        db_dml insert_delivery_method_map {}
    }

    d_proc -public delivery_method_disable {
        {-type_id:required}
        {-delivery_method_id:required}
    } {
    Delivery methods must be enabled on a per notification type basis. For example, full forum posts
    may not be enabled for SMS delivery, as that would be too long.
    This disables a given delivery method for a given notification type.
    } {
        # perform the delete if necessary
        db_dml delete_delivery_method_map {}
    }

    d_proc -public process_reply {
        {-type_id:required}
        {-reply_id:required}
    } {
    The wrapper procedure for processing a given reply. This calls down to the service contract
    implementation to specifically handle a reply.
    } {
        # Get the impl key
        set impl_key [get_impl_key -type_id $type_id]

        # Dispatch to the notification type specific reply processing
        set r [acs_sc::invoke -contract NotificationType -operation ProcessReply -call_args [list $reply_id] -impl $impl_key]
    }

}

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