Index: openacs-4/packages/imsld/imsld.info =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/imsld.info,v diff -u -r1.7 -r1.8 --- openacs-4/packages/imsld/imsld.info 24 Oct 2006 10:09:50 -0000 1.7 +++ openacs-4/packages/imsld/imsld.info 3 Nov 2006 14:39:01 -0000 1.8 @@ -25,6 +25,7 @@ + Index: openacs-4/packages/imsld/catalog/imsld.en_US.ISO-8859-1.xml =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/catalog/imsld.en_US.ISO-8859-1.xml,v diff -u -r1.31 -r1.32 --- openacs-4/packages/imsld/catalog/imsld.en_US.ISO-8859-1.xml 24 Oct 2006 10:09:50 -0000 1.31 +++ openacs-4/packages/imsld/catalog/imsld.en_US.ISO-8859-1.xml 3 Nov 2006 14:39:02 -0000 1.32 @@ -129,7 +129,7 @@ Could not determine whit what program uncompress the file %upload_file% has. Aborting Couldn't determine if this is a well formed IMS-LD: %message% Creaginting new IMS-LD - Dear %recepient_name% <br> \ + Dear %recepient_name% <br> %sender_name has% triggered this notification. Please do not replay to this email. <br> Email Propery Identifier Environment Identifier @@ -271,8 +271,8 @@ <ul> Completed Activities <br /> <ul> %first_or_next% Activity: %activity_name% Uploading and processing your course, please wait... - %username% <br> \ - %sender_name% has triggered this notification. Please do not replay to this email. <br><br> \ + %username% <br> + %sender_name% has triggered this notification. Please do not replay to this email. <br><br> Go to the UoL: <a href=\"%imsld_url%\">%imsld_title%</a> (in the community: <a href=\"%community_url%\">%community_name%</a> community) for further details. Username Property Identifier Valid types are learning, support and structure Index: openacs-4/packages/imsld/tcl/imsld-condition-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-condition-procs.tcl,v diff -u -r1.20 -r1.21 --- openacs-4/packages/imsld/tcl/imsld-condition-procs.tcl 24 Oct 2006 10:09:51 -0000 1.20 +++ openacs-4/packages/imsld/tcl/imsld-condition-procs.tcl 3 Nov 2006 14:39:02 -0000 1.21 @@ -742,6 +742,7 @@ {notification} { set activity_id "" set subjectValue "" + set notified_users_list [list] set subjectNode [$executeNode selectNodes {*[local-name()='subject']}] if { [llength $subjectNode] } { set subjectValue [$subjectNode text] @@ -802,14 +803,15 @@ and run.run_id = :run_id } - imsld::do_notification -imsld_id $imsld_id \ - -run_id $run_id \ - -subject $subjectValue \ - -activity_id $activity_id \ - -username $username \ - -email_address $email_address \ - -role_id $role_id \ - -user_id $user_id + set notified_users_list [imsld::do_notification -imsld_id $imsld_id \ + -run_id $run_id \ + -subject $subjectValue \ + -activity_id $activity_id \ + -username $username \ + -email_address $email_address \ + -role_id $role_id \ + -user_id $user_id \ + -notified_users_list $notified_users_list] } } } Index: openacs-4/packages/imsld/tcl/imsld-install-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-install-procs.tcl,v diff -u -r1.38 -r1.39 --- openacs-4/packages/imsld/tcl/imsld-install-procs.tcl 24 Oct 2006 10:09:51 -0000 1.38 +++ openacs-4/packages/imsld/tcl/imsld-install-procs.tcl 3 Nov 2006 14:39:02 -0000 1.39 @@ -562,6 +562,91 @@ content_revision 0 {} } +ad_proc -public imsld::install::after_upgrade { + -from_version_name:required + -to_version_name:required +} { + apm_upgrade_logic \ + -from_version_name $from_version_name \ + -to_version_name $to_version_name \ + -spec { + 0.01d 1.0d { + ### IMS-LD LEVEL C + + # notifications + content::type::new -content_type imsld_notification -supertype content_revision -pretty_name "#imsld.Notification#" -pretty_plural "#imsld.Notifications#" -table_name imsld_notifications -id_column notification_id + + content::type::attribute::new -content_type imsld_notification -attribute_name imsld_id -datatype number -pretty_name "#imsld.IMS-LD_Identifier#" -column_spec "integer" + content::type::attribute::new -content_type imsld_notification -attribute_name activity_id -datatype number -pretty_name "#imsld.Activity_Identifier#" -column_spec "integer" + content::type::attribute::new -content_type imsld_notification -attribute_name subject -datatype string -pretty_name "#imsld.Notification_Subject#" -column_spec "varchar(4000)" + + # Imsld on completion - notifications + rel_types::new imsld_on_comp_notif_rel "On Completion - Notification" "On Completion - Notifications" \ + content_item 0 {} \ + content_item 0 {} + + # Imsld notification - email datas + rel_types::new imsld_notif_email_rel "Notification - Email Data" "Notification - Email Datas" \ + content_item 0 {} \ + content_item 0 {} + + # Level C, notifications: Runtime assigned activities + # Notifications may set to TRUE the visibility attribute of ANY activity for a given role, + # and by any we mean that the activity does not have to be assigned to a role part associated with that role. + # Therefore we crate this rel type where we map the role with the runtime assigned activities + rel_types::new imsld_run_time_activities_rel "Role - Activity" "Role - Activities" \ + content_revision 0 {} \ + content_revision 0 {} + + # special case: add the new attributes, new rel and migrate the existing data + + content::type::attribute::new -content_type imsld_send_mail_data -attribute_name email_property_id -datatype number -pretty_name "#imsld.lt_Email_Propery_Identif#" -column_spec "integer" + content::type::attribute::new -content_type imsld_send_mail_data -attribute_name username_property_id -datatype number -pretty_name "#imsld.lt_Username_Property_Ide#" -column_spec "integer" + + # Imsld send mail service - email datas + rel_types::new imsld_send_mail_serv_data_rel "Send Mail Service - Email Data" "Send Mail Service - Email Datas" \ + content_item 0 {} \ + content_item 0 {} + + db_foreach send_mail_data { + select serv.username_property_id, + serv.email_property_id, + data.data_id, + data.item_id as data_item_id, + serv.item_id as serv_item_id + from imsld_send_mail_datai data, imsld_send_mail_servicesi serv + where data.send_mail_id = serv.item_id + and content_revision__is_live(serv.mail_id) = 't' + } { + + db_dml update_table { + update imsld_send_mail_data + set email_property_id = :email_property_id, + username_property_id = :username_property_id + where data_id = :data_id + } + + relation_add imsld_notif_email_rel $serv_item_id $data_item_id + } + + + # finally, delete the attributes + content::type::attribute::delete -content_type imsld_send_mail_data \ + -attribute_name send_mail_id \ + -drop_column t + content::type::attribute::delete -content_type imsld_send_mail_service \ + -attribute_name email_property_id \ + -drop_column t + content::type::attribute::delete -content_type imsld_send_mail_service \ + -attribute_name username_property_id \ + -drop_column t + + + } + } +} + + ad_proc -public imsld::uninstall::delete_rels { } { Delete default rels between imsld items Index: openacs-4/packages/imsld/tcl/imsld-procs.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-procs.tcl,v diff -u -r1.89 -r1.90 --- openacs-4/packages/imsld/tcl/imsld-procs.tcl 24 Oct 2006 10:09:51 -0000 1.89 +++ openacs-4/packages/imsld/tcl/imsld-procs.tcl 3 Nov 2006 14:39:02 -0000 1.90 @@ -656,12 +656,25 @@ {-email_address ""} -role_id {-user_id ""} + -notified_users_list } { @param imsld_id + @param run_id + @param subject + @option username + @option email_address + @param role_id + @option user_id user_id of the one sending the notification + @param notified_users_list list to keep track of the notified users + + @return the list of the notified users } { set user_id [expr { [string eq "" $user_id] ? [ad_conn user_id] : $user_id }] # notifications + # according to the spec: "The implementation should ensure that a user receives one notification only, + # even if the user is a member of several roles targeted by the notification", that's why we use the list + # notified_users_list and check before sending the notification. set community_id [dotlrn_community::get_community_id] set community_name [dotlrn_community::get_community_name $community_id] set community_url [ns_conn location][dotlrn_community::get_community_url $community_id] @@ -686,7 +699,7 @@ } } - if { ![empty_string_p $email_address] && [util_email_valid_p $email_address] } { + if { ![empty_string_p $email_address] && [util_email_valid_p $email_address] && ([lsearch -exact $notified_users_list $email_address] == -1) } { # Use this to build up extra mail headers set extra_headers [ns_set new] @@ -706,6 +719,8 @@ -subject $subject \ -body $content \ -extraheaders $extra_headers + + lappend notified_users_list $email_address } else { # invalid mail! ns_log notice "imsld::do_notification: Not sending notification because the email is invalid!" @@ -719,42 +734,49 @@ } # send a notification (email) to each user in the role foreach recipient_user_id [imsld::roles::get_users_in_role -role_id $role_id -run_id $run_id] { - set recepient_name [party::name -party_id $recipient_user_id] - set body_html "[_ imsld.lt_Dear_recepient_name_b]" - # if activity_id is not null: - # 1. make it visible - # 2. get the activity url in order to send it in the email - if { ![empty_string_p $activity_id] } { + set recipient_email [party::email -party_id $recipient_user_id] + if { [lsearch -exact $notified_users_list $email_address] == -1 } { + set recepient_name [party::name -party_id $recipient_user_id] + set body_html "[_ imsld.lt_Dear_recepient_name_b]" + # if activity_id is not null: # 1. make it visible - db_dml make_activity_visible { *SQL* } - # 2. get the activity url for the recipient user_id - set activity_url [imsld::activity_url -run_id $run_id -activity_id $activity_id -user_id $recipient_user_id] - set activity_title [content::revision::revision_name -revision_id $activity_id] - append body_html "[_ imsld.lt_br___________________]" - } else { - append body_html "[_ imsld.lt_br____________________1]" - } - # Use this to build up extra mail headers - set extra_headers [ns_set new] - - # This should disable most auto-replies. - ns_set put $extra_headers Precedence list + # 2. get the activity url in order to send it in the email + if { ![empty_string_p $activity_id] } { + # 1. make it visible + db_dml make_activity_visible { *SQL* } + # 2. get the activity url for the recipient user_id + set activity_url [imsld::activity_url -run_id $run_id -activity_id $activity_id -user_id $recipient_user_id] + set activity_title [content::revision::revision_name -revision_id $activity_id] + append body_html "[_ imsld.lt_br___________________]" + } else { + append body_html "[_ imsld.lt_br____________________1]" + } + # Use this to build up extra mail headers + set extra_headers [ns_set new] + + # This should disable most auto-replies. + ns_set put $extra_headers Precedence list - set message_data [build_mime_message [ad_html_to_text $body_html] $body_html] - ns_set put $extra_headers MIME-Version [ns_set get $message_data MIME-Version] - ns_set put $extra_headers Content-ID [ns_set get $message_data Content-ID] - ns_set put $extra_headers Content-Type [ns_set get $message_data Content-Type] - set content [ns_set get $message_data body] - - acs_mail_lite::send -to_addr [party::email -party_id $recipient_user_id] \ - -from_addr $sender_email \ - -subject $subject \ - -body $content \ - -extraheaders $extra_headers - } + set message_data [build_mime_message [ad_html_to_text $body_html] $body_html] + ns_set put $extra_headers MIME-Version [ns_set get $message_data MIME-Version] + ns_set put $extra_headers Content-ID [ns_set get $message_data Content-ID] + ns_set put $extra_headers Content-Type [ns_set get $message_data Content-Type] + set content [ns_set get $message_data body] + + acs_mail_lite::send -to_addr $recipient_email \ + -from_addr $sender_email \ + -subject $subject \ + -body $content \ + -extraheaders $extra_headers + lappend notified_users_list $recipient_email + } + } + # log the notification db_dml log_notification { *SQL* } + + return $notified_users_list } ad_proc -public imsld::finish_component_element { @@ -844,6 +866,7 @@ imsld::condition::eval_change_property_value -change_property_value_xml $change_property_value_xml -run_id $run_id } # notifications + set notified_users_list [list] foreach notification_list [db_list_of_lists get_notifications { *SQL* }] { set subject [lindex $notification_list 0] set activity_id [content::item::get_live_revision -item_id [lindex $notification_list 1]] @@ -862,7 +885,9 @@ # NOTE: there is no specification for the format of the email property value # so we assume it is a single username db_1row get_username_property_id { *SQL* } - set username [imsld::runtime::property::property_value_get -run_id $run_id -user_id $user_id -property_id $property_id] + set username [imsld::runtime::property::property_value_get -run_id $run_id \ + -user_id $user_id \ + -property_id $property_id] } else { set username "" } @@ -873,19 +898,22 @@ # so we assume it is a single email address. # we also send the notificaiton to the rest of the role members db_1row get_email_property_id { *SQL* } - set email_address [imsld::runtime::property::property_value_get -run_id $run_id -user_id $user_id -property_id $property_id] + set email_address [imsld::runtime::property::property_value_get -run_id $run_id \ + -user_id $user_id \ + -property_id $property_id] } else { set email_address "" } - imsld::do_notification -imsld_id $imsld_id \ - -run_id $run_id \ - -subject $subject \ - -activity_id $activity_id \ - -username $username \ - -email_address $email_address \ - -role_id $role_id \ - -user_id $user_id + set notified_users_list [imsld::do_notification -imsld_id $imsld_id \ + -run_id $run_id \ + -subject $subject \ + -activity_id $activity_id \ + -username $username \ + -email_address $email_address \ + -role_id $role_id \ + -user_id $user_id \ + -notified_users_list $notified_users_list] } } } Index: openacs-4/packages/imsld/tcl/imsld-procs.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/tcl/imsld-procs.xql,v diff -u -r1.34 -r1.35 --- openacs-4/packages/imsld/tcl/imsld-procs.xql 30 Oct 2006 12:14:34 -0000 1.34 +++ openacs-4/packages/imsld/tcl/imsld-procs.xql 3 Nov 2006 14:39:02 -0000 1.35 @@ -1135,7 +1135,7 @@ - select sm.title as send_mail_title, ar.object_id_two as sendmail_id + select sm.title as send_mail_title, sm.mail_id as sendmail_id from imsld_send_mail_servicesi sm, acs_rels ar where sm.service_id = :service_item_id and sm.item_id = ar.object_id_one Index: openacs-4/packages/imsld/www/imsld-content-serve.tcl =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/imsld-content-serve.tcl,v diff -u -r1.16 -r1.17 --- openacs-4/packages/imsld/www/imsld-content-serve.tcl 24 Oct 2006 10:09:51 -0000 1.16 +++ openacs-4/packages/imsld/www/imsld-content-serve.tcl 3 Nov 2006 14:39:03 -0000 1.17 @@ -341,6 +341,7 @@ $form_node removeAttribute xmlns # level C: notifications + set notified_users_list [list] foreach notification_node [$set_property_node selectNodes "*\[local-name()='notification'\]"] { set activity_id "" set subjectValue "" @@ -404,14 +405,15 @@ and run.run_id = :run_id } - imsld::do_notification -imsld_id $imsld_id \ - -run_id $run_id \ - -subject $subjectValue \ - -activity_id $activity_id \ - -username $username \ - -email_address $email_address \ - -role_id $role_id \ - -user_id $owner_user_id + set notified_users_list [imsld::do_notification -imsld_id $imsld_id \ + -run_id $run_id \ + -subject $subjectValue \ + -activity_id $activity_id \ + -username $username \ + -email_address $email_address \ + -role_id $role_id \ + -user_id $owner_user_id \ + -notified_users_list $notified_users_list] } } } Index: openacs-4/packages/imsld/www/imsld-sendmail.xql =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/imsld/www/imsld-sendmail.xql,v diff -u -r1.2 -r1.3 --- openacs-4/packages/imsld/www/imsld-sendmail.xql 30 Oct 2006 12:14:35 -0000 1.2 +++ openacs-4/packages/imsld/www/imsld-sendmail.xql 3 Nov 2006 14:39:03 -0000 1.3 @@ -5,15 +5,17 @@ select iri.title, iri.role_id as group_recipient, - isms.recipients - from imsld_send_mail_datai ismd, - acs_rels ar, - imsld_send_mail_servicesi isms, + isms.recipients + from imsld_send_mail_datai ismd, + imsld_send_mail_servicesi isms, + acs_rels ar, imsld_rolesi iri - where ismd.item_id=:send_mail_id - and ar.object_id_two=ismd.item_id - and ar.object_id_one=isms.item_id - and iri.item_id=ismd.role_id + where ar.object_id_two = ismd.item_id + and ar.rel_type = 'imsld_send_mail_serv_data_rel' + and ar.object_id_one = isms.item_id + and isms.mail_id = :send_mail_id + and iri.item_id = ismd.role_id +