[LON-CAPA-cvs] cvs: loncom /interface lonmsg.pm

raeburn raeburn@source.lon-capa.org
Fri, 19 Dec 2008 02:43:52 -0000


raeburn		Fri Dec 19 02:43:52 2008 EDT

  Modified files:              
    /loncom/interface	lonmsg.pm 
  Log:
  - Check if homeserver uses https protocol, and provide appropriate URL in notifiction e-mail.
  - Remove machine specification with http or https from baseurl and attahmenturl when packaging message. 
  
  
Index: loncom/interface/lonmsg.pm
diff -u loncom/interface/lonmsg.pm:1.217 loncom/interface/lonmsg.pm:1.218
--- loncom/interface/lonmsg.pm:1.217	Sat Dec  6 20:29:18 2008
+++ loncom/interface/lonmsg.pm	Fri Dec 19 02:43:52 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Routines for messaging
 #
-# $Id: lonmsg.pm,v 1.217 2008/12/06 20:29:18 schafran Exp $
+# $Id: lonmsg.pm,v 1.218 2008/12/19 02:43:52 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -224,10 +224,10 @@
     $citation=&HTML::Entities::encode($citation,'<>&"');
     $subject =&HTML::Entities::encode($subject,'<>&"');
     #remove machine specification
-    $baseurl =~ s|^http://[^/]+/|/|;
+    $baseurl =~ s|^https?://[^/]+/|/|;
     $baseurl =&HTML::Entities::encode($baseurl,'<>&"');
     #remove machine specification
-    $attachmenturl =~ s|^http://[^/]+/|/|;
+    $attachmenturl =~ s|^https?://[^/]+/|/|;
     $attachmenturl =&HTML::Entities::encode($attachmenturl,'<>&"');
     my $course_context = &get_course_context();
     my $now=time;
@@ -455,9 +455,11 @@
 
     $text=~s/\&lt\;/\</gs;
     $text=~s/\&gt\;/\>/gs;
-    my $url='http://'.
-	&Apache::lonnet::hostname(&Apache::lonnet::homeserver($touname,$toudom)).
-      '/adm/email?username='.$touname.'&domain='.$toudom;
+    my $homeserver = &Apache::lonnet::homeserver($touname,$toudom);
+    my $protocol = $Apache::lonnet::protocol{$homeserver};
+    $protocol = 'http' if ($protocol ne 'https');
+    my $url = $protocol.'://'.&Apache::lonnet::hostname($homeserver).
+              '/adm/email?username='.$touname.'&domain='.$toudom;
     my ($sendtime,$shortsubj,$fromname,$fromdomain,$status,$fromcid,
         $symb,$error) = &Apache::lonmsg::unpackmsgid($msgid);
     my ($coursetext,$body,$bodybegin,$bodysubj,$bodyend);