Here's how to derive the host mapped "manage url" in notifications, given the recipient's user_id:
+ fullquery name="scs::subsite_url_from_user_id.select_group_id_from_user_id"
+ querytext
+ select object_id_one as group_id
+ from acs_rels
+ where object_id_two = :user_id
+ and object_id_one in (select group_id
+ from application_groups)
+ and object_id_one > 0
+ limit 1
+ /querytext
+ /fullquery
+
+ fullquery name="scs::subsite_url_from_user_id.select_host"
+ querytext
+ select "http://"||host
+ from host_node_map
+ where node_id = :node_id
+ limit 1
+ /querytext
+ /fullquery
+
/queryset
+
+ad_proc -public scs::subsite_url_from_user_id {
+ {-user_id:required}
+} {
+ Derives the first absolute, host-mapped subsite url given the user_id.
+ Useful for determining the subsite url in a scheduled proc, such as notifications.
+ Assumes that user_id belongs to one and only one subsite application group.
+ If a host-mapped entry is not found, return the system url.
+} {
+
+ db_1row select_group_id_from_user_id {}
+
+ set node_id [site_node::get_node_id_from_object_id \
+ -object_id [application_group::package_id_from_group_id \
+ -group_id $group_id]]
+
+ return [db_string select_host {} -default "[ad_url]"]
+
+}
Index: notifications/tcl/notification-email-procs.tcl
===================================================================
--- notifications/tcl/notification-email-procs.tcl (revision 214)
+++ notifications/tcl/notification-email-procs.tcl (working copy)
@@ -43,10 +43,13 @@
return $domain
}
- ad_proc -public manage_notifications_url {} {
+ ad_proc -public manage_notifications_url {
+ {-to_user_id:required}
+ } {
Build a url to the "manage notifications" script.
+ Supports host mapped subsites.
} {
- return "[ad_url][apm_package_url_from_key [notification::package_key]]manage"
+ return "[scs::subsite_url_from_user_id -user_id $to_user_id][apm_package_url_from_key [notification::package_key]]manage"
}
ad_proc -public reply_address_prefix {} {
@@ -123,7 +126,7 @@
}
# Variable used in the content
- set manage_notifications_url [manage_notifications_url]
+ set manage_notifications_url [manage_notifications_url -to_user_id $to_user_id]
if { [string length $content_html] == 0 } {
set mime_type "text/plain"