notification-request-procs.tcl

Notification Requests When a user wishes to receive notifications of a certain type on a given object, he issues a notification request. This request is recorded specifically for that user. These procs help to manage such requests.

Location:
packages/notifications/tcl/notification-request-procs.tcl
Created:
2002-05-24
Author:
Ben Adida
CVS Identification:
$Id: notification-request-procs.tcl,v 1.14.2.2 2022/07/12 14:15:11 antoniop Exp $

Procedures in this file

Detailed information

notification::request::delete (public)

 notification::request::delete -request_id request_id

delete a request for notifications by request ID.

Switches:
-request_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 notification::sweep::cleanup_notifications notification::sweep::cleanup_notifications (private) notification::request::delete notification::request::delete notification::sweep::cleanup_notifications->notification::request::delete packages/forums/www/admin/subscribe-others-2.tcl packages/forums/ www/admin/subscribe-others-2.tcl packages/forums/www/admin/subscribe-others-2.tcl->notification::request::delete packages/notifications/www/request-delete.tcl packages/notifications/ www/request-delete.tcl packages/notifications/www/request-delete.tcl->notification::request::delete packages/notifications/www/unsubscribe.tcl packages/notifications/ www/unsubscribe.tcl packages/notifications/www/unsubscribe.tcl->notification::request::delete db_exec_plsql db_exec_plsql (public) notification::request::delete->db_exec_plsql

Testcases:
No testcase defined.

notification::request::delete_all (public)

 notification::request::delete_all -object_id object_id

remove all requests for a particular object ID usually because the object is getting deleted.

Switches:
-object_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 forum::message::delete forum::message::delete (public) notification::request::delete_all notification::request::delete_all forum::message::delete->notification::request::delete_all db_exec_plsql db_exec_plsql (public) notification::request::delete_all->db_exec_plsql

Testcases:
No testcase defined.

notification::request::delete_all_for_user (public)

 notification::request::delete_all_for_user -user_id user_id

delete all the requests for a given user

Switches:
-user_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 db_exec_plsql db_exec_plsql (public) notification::request::delete_all_for_user notification::request::delete_all_for_user notification::request::delete_all_for_user->db_exec_plsql

Testcases:
No testcase defined.

notification::request::get_request_id (public)

 notification::request::get_request_id -type_id type_id \
    -object_id object_id -user_id user_id

Checks if a particular notification request exists, and if so return the request ID. Note that the primary key on notification requests is notification_type, object, user. Interval and delivery method are specific parameters, but do not impact the uniqueness: a user can choose only one interval and delivery method for a given notification type and object.

Switches:
-type_id (required)
-object_id (required)
-user_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 bug_tracker::bug::get_watch_link bug_tracker::bug::get_watch_link (public) notification::request::get_request_id notification::request::get_request_id bug_tracker::bug::get_watch_link->notification::request::get_request_id notification::display::get_urls notification::display::get_urls (public) notification::display::get_urls->notification::request::get_request_id notification::display::request_widget notification::display::request_widget (public) notification::display::request_widget->notification::request::get_request_id notification::request::new notification::request::new (public) notification::request::new->notification::request::get_request_id packages/bug-tracker/www/notifications.tcl packages/bug-tracker/ www/notifications.tcl packages/bug-tracker/www/notifications.tcl->notification::request::get_request_id db_string db_string (public) notification::request::get_request_id->db_string

Testcases:
No testcase defined.

notification::request::new (public)

 notification::request::new [ -request_id request_id ] -type_id type_id \
    -user_id user_id -object_id object_id -interval_id interval_id \
    -delivery_method_id delivery_method_id [ -format format ] \
    [ -dynamic_p dynamic_p ]

create a new request for a given user, notification type, object, interval and delivery method.

Switches:
-request_id (optional)
-type_id (required)
-user_id (required)
-object_id (required)
-interval_id (required)
-delivery_method_id (required)
-format (optional, defaults to "text")
-dynamic_p (optional, defaults to "f")

Partial Call Graph (max 5 caller/called nodes):
%3 notification::new notification::new (public) notification::request::new notification::request::new notification::new->notification::request::new packages/forums/www/admin/subscribe-others-2.tcl packages/forums/ www/admin/subscribe-others-2.tcl packages/forums/www/admin/subscribe-others-2.tcl->notification::request::new packages/notifications/www/request-new-2.tcl packages/notifications/ www/request-new-2.tcl packages/notifications/www/request-new-2.tcl->notification::request::new packages/notifications/www/request-new.tcl packages/notifications/ www/request-new.tcl packages/notifications/www/request-new.tcl->notification::request::new packages/notifications/www/request-notification.tcl packages/notifications/ www/request-notification.tcl packages/notifications/www/request-notification.tcl->notification::request::new notification::request::get_request_id notification::request::get_request_id (public) notification::request::new->notification::request::get_request_id package_instantiate_object package_instantiate_object (public) notification::request::new->package_instantiate_object

Testcases:
No testcase defined.

notification::request::request_count (public)

 notification::request::request_count -type_id type_id \
    -object_id object_id

returns number of notification requests for this type and object

Switches:
-type_id (required)
-object_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 packages/forums/www/forum-view.tcl packages/forums/ www/forum-view.tcl notification::request::request_count notification::request::request_count packages/forums/www/forum-view.tcl->notification::request::request_count db_string db_string (public) notification::request::request_count->db_string

Testcases:
No testcase defined.

notification::request::request_exists (public)

 notification::request::request_exists -type_id type_id \
    -object_id object_id

returns true if at least one request exists for this object and type

Switches:
-type_id (required)
-object_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 notification::new notification::new (public) notification::request::request_exists notification::request::request_exists notification::new->notification::request::request_exists db_0or1row db_0or1row (public) notification::request::request_exists->db_0or1row

Testcases:
No testcase defined.

notification::request::request_ids (public)

 notification::request::request_ids -type_id type_id \
    -object_id object_id

returns a list of request_ids for the object_id of the given type

Switches:
-type_id (required)
-object_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 packages/forums/www/admin/subscribe-others-2.tcl packages/forums/ www/admin/subscribe-others-2.tcl notification::request::request_ids notification::request::request_ids packages/forums/www/admin/subscribe-others-2.tcl->notification::request::request_ids db_list db_list (public) notification::request::request_ids->db_list

Testcases:
No testcase defined.

notification::request::subscribers (public)

 notification::request::subscribers -type_id type_id \
    -object_id object_id

returns a list of subscribers for notifications on that object of this type

Switches:
-type_id (required)
-object_id (required)

Partial Call Graph (max 5 caller/called nodes):
%3 packages/forums/www/admin/subscribe-others.tcl packages/forums/ www/admin/subscribe-others.tcl notification::request::subscribers notification::request::subscribers packages/forums/www/admin/subscribe-others.tcl->notification::request::subscribers db_list db_list (public) notification::request::subscribers->db_list

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

Content File Source

ad_library {

    Notification Requests

    When a user wishes to receive notifications of a certain type on a given object,
    he issues a notification request. This request is recorded specifically for that user.
    These procs help to manage such requests.

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

}

namespace eval notification::request {

    d_proc -public new {
        {-request_id ""}
        {-type_id:required}
        {-user_id:required}
        {-object_id:required}
        {-interval_id:required}
        {-delivery_method_id:required}
        {-format "text"}
        {-dynamic_p "f"}
    } {
        create a new request for a given user, notification type, object, interval and delivery method.
    } {
        set request_id [get_request_id -type_id $type_id -object_id $object_id -user_id $user_id]

        if {$request_id eq ""} {
            # Set up the vars
            set extra_vars [ns_set create s \
                                request_id $request_id \
                                type_id $type_id \
                                user_id $user_id \
                                object_id $object_id \
                                interval_id $interval_id \
                                delivery_method_id $delivery_method_id \
                                format $format \
                                dynamic_p $dynamic_p \
                               ]

            # Create the request
            set request_id [package_instantiate_object -extra_vars $extra_vars notification_request]
        }

        return $request_id
    }

    d_proc -public get_request_id {
        {-type_id:required}
        {-object_id:required}
        {-user_id:required}
    } {
        Checks if a particular notification request exists, and if so return the request ID.
        Note that the primary key on notification requests is notification_type, object, user.
        Interval and delivery method are specific parameters, but do not impact the uniqueness:
        a user can choose only one interval and delivery method for a given notification type and object.
    } {
        return [db_string select_request_id {} -default {}]
    }

    d_proc -public request_exists {
        {-type_id:required}
        {-object_id:required}
    } {
        returns true if at least one request exists for this object and type
    } {
        return [db_0or1row exists {
            select 1 from notification_requests
            where type_id = :type_id
            and object_id = :object_id
            fetch first 1 rows only
        }]
    }

    d_proc -public request_count {
        {-type_id:required}
        {-object_id:required}
    } {
        returns number of notification requests for this type and object
    } {
        return [db_string request_count {} -default 0]
    }

    d_proc -public subscribers {
        {-type_id:required}
        {-object_id:required}
    } {
        returns a list of subscribers for notifications on that object of this type
    } {
        return [db_list request_subscribers {}]
    }

    d_proc -public request_ids {
        {-type_id:required}
        {-object_id:required}
    } {
        returns a list of request_ids for the object_id of the given type
    } {
        return [db_list request_ids {}]
    }

    d_proc -public delete {
        {-request_id:required}
    } {
        delete a request for notifications by request ID.
    } {
        # do the delete
        db_exec_plsql delete_request {}
    }

    d_proc -public delete_all {
        {-object_id:required}
    } {
        remove all requests for a particular object ID
        usually because the object is getting deleted.
    } {
        # Do it
        db_exec_plsql delete_all_requests {}
    }

    d_proc -public delete_all_for_user {
        {-user_id:required}
    } {
        delete all the requests for a given user
    } {
        # do the delete
        db_exec_plsql delete_all_for_user {}
    }
}

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