[LON-CAPA-cvs] cvs: loncom /auth lonacc.pm lonauth.pm lonlogin.pm lonroles.pm migrateuser.pm switchserver.pm

albertel lon-capa-cvs@mail.lon-capa.org
Wed, 05 Apr 2006 22:39:56 -0000


This is a MIME encoded message

--albertel1144276796
Content-Type: text/plain

albertel		Wed Apr  5 18:39:56 2006 EDT

  Modified files:              
    /loncom/auth	lonacc.pm lonauth.pm lonlogin.pm lonroles.pm 
                	migrateuser.pm switchserver.pm 
  Log:
  - start_page
  
  
--albertel1144276796
Content-Type: text/plain
Content-Disposition: attachment; filename="albertel-20060405183956.txt"

Index: loncom/auth/lonacc.pm
diff -u loncom/auth/lonacc.pm:1.73 loncom/auth/lonacc.pm:1.74
--- loncom/auth/lonacc.pm:1.73	Fri Jan 27 17:28:37 2006
+++ loncom/auth/lonacc.pm	Wed Apr  5 18:39:55 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Cookie Based Access Handler
 #
-# $Id: lonacc.pm,v 1.73 2006/01/27 22:28:37 raeburn Exp $
+# $Id: lonacc.pm,v 1.74 2006/04/05 22:39:55 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -148,7 +148,7 @@
 			     (($requrl=~m|(.*)/smpedit$|) &&
 			      &Apache::lonnet::symbverify($symb,$1))) {
                       my ($map,$mid,$murl)=&Apache::lonnet::decode_symb($symb);
-                      &Apache::lonnet::symblist($map,$murl => [$murl,$mid],
+		      &Apache::lonnet::symblist($map,$murl => [$murl,$mid],
 						'last_known' =>[$murl,$mid]);
 		    } else {
 			$r->log_reason('Invalid symb for '.$requrl.': '.
Index: loncom/auth/lonauth.pm
diff -u loncom/auth/lonauth.pm:1.73 loncom/auth/lonauth.pm:1.74
--- loncom/auth/lonauth.pm:1.73	Thu Jan 19 17:14:38 2006
+++ loncom/auth/lonauth.pm	Wed Apr  5 18:39:55 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # User Authentication Module
 #
-# $Id: lonauth.pm,v 1.73 2006/01/19 22:14:38 albertel Exp $
+# $Id: lonauth.pm,v 1.74 2006/04/05 22:39:55 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -210,8 +210,10 @@
     my $remoteinfo=&Apache::lonmenu::load_remote_msg($lowerurl);
     my $setflags=&Apache::lonmenu::setflags();
     my $maincall=&Apache::lonmenu::maincall();
-    my $bodytag=&Apache::loncommon::bodytag('Successful Login');
-    my $add=&addcontent();
+    my $start_page=&Apache::loncommon::start_page('Successful Login',
+						  $startupremote);
+    my $end_page  =&Apache::loncommon::end_page();
+
     my $continuelink;
     if (($env{'browser.interface'} eq 'textual') ||
         ($env{'environment.remote'} eq 'off')) {
@@ -219,11 +221,10 @@
     }
 # ------------------------------------------------- Output for successful login
 
-    $r->send_cgi_header(<<ENDHEADER);
-Content-type: text/html$add
-Set-cookie: $cookie
+    &Apache::loncommon::content_type($r,'text/html');
+    $r->header_out('Set-cookie' => $cookie);
+    $r->send_http_header;
 
-ENDHEADER
     my %lt=&Apache::lonlocal::texthash(
 				       'wel' => 'Welcome',
 				       'mes' => 'Welcome to the Learning<i>Online</i> Network with CAPA. Please wait while your session is being set up',
@@ -231,12 +232,7 @@
 				       'log' => 'loginproblems.html',
 				       );
     $r->print(<<ENDSUCCESS);
-<html>
-<head>
-<title>Successful Login to the LearningOnline Network with CAPA</title>
-$startupremote
-</head>
-$bodytag
+$start_page
 $setflags
 $windowinfo
 <h1>$lt{'wel'}</h1>
@@ -245,8 +241,7 @@
 $remoteinfo
 $maincall
 $continuelink
-</body>
-</html>
+$end_page
 ENDSUCCESS
 }
 
@@ -254,59 +249,40 @@
 
 sub failed {
     my ($r,$message) = @_;
-    my $bodytag=&Apache::loncommon::bodytag('Unsuccessful Login');
-    my $add=&addcontent();
-    $r->send_cgi_header(<<ENDFHEADER);
-Content-type: text/html$add
+    my $start_page = &Apache::loncommon::start_page('Unsuccessful Login');
+    my $end_page   = &Apache::loncommon::end_page();
+
+    my %lt=('sorry'  => &mt('Sorry ...'),
+	    'please' => 
+	    &mt('Please [_1]log in again[_2].',
+		"<a href=\"/adm/login?username=$FORM{'uname'}&domain=$FORM{'udom'}\">",
+		'</a>'),
+	    'problemspage' => &mt('loginproblems.html'),
+	    'problems'     => 'Problems',
+	    );
+    &Apache::loncommon::content_type($r,'text/html');
+    $r->send_http_header;
 
-ENDFHEADER
     $r->print(<<ENDFAILED);
-<html>
-<head>
-<title>Unsuccessful Login to the LearningOnline Network with CAPA</title>
-</head>
-$bodytag
-<h1>Sorry ...</h1>
+$start_page
+<h1>$lt{'sorry'}</h1>
 <p><b>$message</b></p>
-<p>Please <a href="/adm/login?username=$FORM{'uname'}&domain=$FORM{'udom'}">log in again</a>.</p>
+<p>$lt{'please'}</p>
 <p>
-<a href="/adm/loginproblems.html">Problems?</a></p>
-</body>
-</html>
+<a href="/adm/$lt{'problemspage'}">$lt{'problems'}</a></p>
+$end_page
 ENDFAILED
 }
 
-# --------------------------------------------------------------------- Charset
-
-sub addcontent {
-    my $encoding=&Apache::lonlocal::current_encoding;
-    if ($encoding) {
-	return '; charset='.$encoding;
-    } else {
-	return '';
-    }
-}
-
 # ------------------------------------------------------------------ Rerouting!
 
 sub reroute {
-    my $r=shift;
-    my $bodytag=&Apache::loncommon::bodytag('Rerouting');
-    $r->send_cgi_header(<<ENDRFHEADER);
-Content-type: text/html
-
-ENDRFHEADER
-    $r->print(<<ENDRFAILED);
-<html>
-<head>
-<title>Rerouting Login to the LearningOnline Network with CAPA</title>
-</head>
-$bodytag
-<h1>Sorry ...</h1>
-Please <a href="/">log in again</a>.
-</body>
-</html>
-ENDRFAILED
+    my ($r) = @_;
+    &Apache::loncommon::content_type($r,'text/html');
+    $r->send_http_header;
+    my $msg='<h1>Sorry ...</h1>
+             Please <a href="/">log in again</a>.';
+    &Apache::loncommon::simple_error_page($r,'Rerouting',$msg);
 }
 
 # ---------------------------------------------------------------- Main handler
@@ -332,24 +308,20 @@
         my $lonidsdir=$r->dir_config('lonIDsDir');
         if ((-e "$lonidsdir/$handle.id") && ($handle ne '')) {
 # Indeed, a valid token is found
-	    $r->send_cgi_header(<<ENDFHEADER);
-Content-type: text/html
-
-ENDFHEADER
-	    my $bodytag=&Apache::loncommon::bodytag('Already logged in');
+	    &Apache::loncommon::content_type($r,'text/html');
+	    $r->send_http_header;
+	    my $start_page = 
+		&Apache::loncommon::start_page('Already logged in');
+	    my $end_page = 
+		&Apache::loncommon::end_page();
 	    $r->print(<<ENDFAILED);
-<html>
-<head>
-<title>Already logged in</title>
-</head>
-$bodytag
+$start_page
 <h1>You are already logged in</h1>
 <p>Please either <a href="/adm/roles">continue the current session</a> or
 <a href="/adm/logout">logout</a>.</p>
 <p>
 <a href="/adm/loginproblems.html">Problems?</a></p>
-</body>
-</html>
+$end_page
 ENDFAILED
            return OK;
 	}
Index: loncom/auth/lonlogin.pm
diff -u loncom/auth/lonlogin.pm:1.73 loncom/auth/lonlogin.pm:1.74
--- loncom/auth/lonlogin.pm:1.73	Tue Feb 28 11:44:19 2006
+++ loncom/auth/lonlogin.pm	Wed Apr  5 18:39:55 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Login Screen
 #
-# $Id: lonlogin.pm,v 1.73 2006/02/28 16:44:19 albertel Exp $
+# $Id: lonlogin.pm,v 1.74 2006/04/05 22:39:55 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -80,20 +80,18 @@
 		unlink("$lonidsdir/$handle.id");
 	    } elsif ($handle ne '') {
 # Indeed, a valid token is found
-		my $bodytag=&Apache::loncommon::bodytag('Already logged in');
+		my $start_page = 
+		    &Apache::loncommon::start_page('Already logged in');
+		my $end_page = 
+		    &Apache::loncommon::end_page();
 		$r->print(<<ENDFAILED);
-<html>
-<head>
-<title>Already logged in</title>
-</head>
-$bodytag
+$start_page
 <h1>You are already logged in</h1>
 <p>Please either <a href="/adm/roles">continue the current session</a> or
 <a href="/adm/logout">logout</a>.</p>
 <p>
 <a href="/adm/loginproblems.html">Problems?</a></p>
-</body>
-</html>
+$end_page
 ENDFAILED
                 return OK;
  	    }  
Index: loncom/auth/lonroles.pm
diff -u loncom/auth/lonroles.pm:1.146 loncom/auth/lonroles.pm:1.147
--- loncom/auth/lonroles.pm:1.146	Thu Mar 16 14:19:59 2006
+++ loncom/auth/lonroles.pm	Wed Apr  5 18:39:55 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # User Roles Screen
 #
-# $Id: lonroles.pm,v 1.146 2006/03/16 19:19:59 raeburn Exp $
+# $Id: lonroles.pm,v 1.147 2006/04/05 22:39:55 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -55,24 +55,21 @@
     } else {
 	$navwindow.=&Apache::lonnavmaps::close();
     }
-    my $bodytag=&Apache::loncommon::bodytag('Switching Role');
+    my $start_page = &Apache::loncommon::start_page('Switching Role',undef,
+						    {'redirect' => [1,$url],});
+    my $end_page   = &Apache::loncommon::end_page();
+
 # Note to style police: 
 # This must only replace the spaces, nothing else, or it bombs elsewhere.
     $url=~s/ /\%20/g;
     $r->print(<<ENDREDIR);
-<head><title>$title</title>
-<meta HTTP-EQUIV="Refresh" CONTENT="1; url=$url">
-</head>
-<html>
-$bodytag
+$start_page
 <script type="text/javascript">
 $swinfo
 </script>
 $navwindow
 <h1>$msg</h1>
-<a href="$url">Continue</a>
-</body>
-</html>
+$end_page
 ENDREDIR
     return;
 }
@@ -159,8 +156,9 @@
 				 &Apache::loncommon::no_cache($r);
 				 $r->send_http_header;
 				 my $swinfo=&Apache::lonmenu::rawconfig();
-				 my $bodytag=&Apache::loncommon::bodytag
+				 my $start_page=&Apache::loncommon::start_page
 				    ('Verifying Access Key to Unlock this Course');
+				 my $end_page=&Apache::loncommon::end_page();
 				 my $buttontext=&mt('Enter Course');
 				 my $message=&mt('Successfully registered key');
 				 my $assignresult=
@@ -180,10 +178,7 @@
 				     $buttontext=&mt('Re-Enter Key');
 				 }
 				 $r->print(<<ENDENTEREDKEY);
-<head><title>Verifying Course Access Key</title>
-</head>
-<html>
-$bodytag
+$start_page
 <script>
 $swinfo
 </script>
@@ -193,7 +188,7 @@
 <font size="+2">$message</font><br />
 <input type="submit" value="$buttontext" />
 </form>
-</body></html>
+$end_page
 ENDENTEREDKEY
                                  return OK;
 			     } else {
@@ -202,13 +197,11 @@
 				 &Apache::loncommon::no_cache($r);
 				 $r->send_http_header;
 				 my $swinfo=&Apache::lonmenu::rawconfig();
-				 my $bodytag=&Apache::loncommon::bodytag
+				 my $start_page=&Apache::loncommon::start_page
 				    ('Enter Access Key to Unlock this Course');
+				 my $end_page=&Apache::loncommon::end_page();
 				 $r->print(<<ENDENTERKEY);
-<head><title>Entering Course Access Key</title>
-</head>
-<html>
-$bodytag
+$start_page
 <script>
 $swinfo
 </script>
@@ -218,7 +211,7 @@
 <input type="text" size="20" name="newkey" value="$env{'form.newkey'}" />
 <input type="submit" value="Enter key" />
 </form>
-</body></html>
+$end_page
 ENDENTERKEY
 				 return OK;
 			     }
@@ -329,16 +322,12 @@
     return OK if $r->header_only;
 
     my $swinfo=&Apache::lonmenu::rawconfig();
-    my $bodytag=&Apache::loncommon::bodytag('User Roles');
+    my $start_page=&Apache::loncommon::start_page('User Roles');
     my $standby=&mt('Role selected. Please stand by.');
     $standby=~s/\n/\\n/g;
     my $helptag='<table><tr><td>'.&Apache::loncommon::help_open_menu('','General Intro','General_Intro','User Roles',1,undef,undef,undef,undef,,&mt("Click here for help")).'</td></td></tr></table>';
     $r->print(<<ENDHEADER);
-<html>
-<head>
-<title>LON-CAPA User Roles</title>
-</head>
-$bodytag
+$start_page
 $helptag<br />
 <script>
 $swinfo
@@ -412,7 +401,8 @@
 	    } else {
 		$r->print(&mt(' a certain'));
 	    } 
-	    $r->print(&mt(' course.').'</body></html>');
+	    $r->print(&mt(' course.').
+		      &Apache::loncommon::end_page());
 	    return OK;
         } 
     } else {
@@ -601,7 +591,7 @@
 	} else {
 	    $r->print('<h2>'.&mt('Currently no active roles or courses').'</h2>');
 	}
-	$r->print('</form></body></html>');
+	$r->print('</form>'.&Apache::loncommon::end_page());
 	return OK;
 # Is there only one choice?
     } elsif (($countactive==1) && ($env{'request.role'} eq 'cm')) {
@@ -610,7 +600,7 @@
 	$r->print("</form>\n");
 	$r->rflush();
 	$r->print('<script>document.forms.rolechoice.submit();</script>');
-	$r->print('</body></html>');
+	$r->print(&Apache::loncommon::end_page());
 	return OK;
     }
 # More than one possible role
@@ -767,7 +757,7 @@
 		  $r->dir_config('lonVersion').'</i><br />'.
 		  '<a href="/adm/logout">'.&mt('Logout').'</a></small></p>');
     }
-    $r->print("</body></html>\n");
+    $r->print(&Apache::loncommon::end_page());
     return OK;
 }
 
Index: loncom/auth/migrateuser.pm
diff -u loncom/auth/migrateuser.pm:1.4 loncom/auth/migrateuser.pm:1.5
--- loncom/auth/migrateuser.pm:1.4	Wed Dec 28 14:26:02 2005
+++ loncom/auth/migrateuser.pm	Wed Apr  5 18:39:55 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Starts a user off based of an existing token.
 #
-# $Id: migrateuser.pm,v 1.4 2005/12/28 19:26:02 albertel Exp $
+# $Id: migrateuser.pm,v 1.5 2006/04/05 22:39:55 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -37,21 +37,12 @@
     my ($r) = @_;
     &Apache::loncommon::content_type($r,'text/html');
     $r->send_http_header;
-    $r->print(<<TOLOGIN);
-<html>
-  <head>
-    <meta http-equiv="refresh" content="0;url=/adm/login" />
-    <title>Going to login</title>
-  </head>
-  <body>
-    <h1>One moment please...</h1>
-    <p>
-      Transferring to login page.
-      <a href="/adm/login">Continue</a>
-    </p>
-  </body>
-</html>
-TOLOGIN
+    $r->print(&Apache::loncommon::start_page('Going to login',undef,
+					     {'redirect' =>
+						  [0,'/adm/login'],}).
+	      '<h1>'.&mt('One moment please...').'</h1>'.
+	      '<p>'.&mt('Transferring to login page.').'</p>'.
+	      &Apache::loncommon::end_page());
     return OK;
 }
 
Index: loncom/auth/switchserver.pm
diff -u loncom/auth/switchserver.pm:1.6 loncom/auth/switchserver.pm:1.7
--- loncom/auth/switchserver.pm:1.6	Wed Dec 28 11:46:47 2005
+++ loncom/auth/switchserver.pm	Wed Apr  5 18:39:55 2006
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Switch Servers Handler
 #
-# $Id: switchserver.pm,v 1.6 2005/12/28 16:46:47 albertel Exp $
+# $Id: switchserver.pm,v 1.7 2006/04/05 22:39:55 albertel Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -105,18 +105,11 @@
 	      'server'   => $r->dir_config('lonHostID'));
     my $token = &Apache::lonnet::tmpput(\%info,$env{'form.otherserver'});
     my $switch='<meta HTTP-EQUIV="Refresh" CONTENT="0.5; url=http://'.$switch_to.'/adm/login?domain='.$env{'user.domain'}.'&username='.$env{'user.name'}.'&token='.$token.'">';
-    my $bodytag=&Apache::loncommon::bodytag('Switching Server ...');
+    my $start_page = &Apache::loncommon::start_page('Switching Server ...',
+						    $switch);
+    my $end_page   = &Apache::loncommon::end_page();
 # --------------------------------------------------------------- Screen Output
-    $r->print(<<ENDDOCUMENT);
-	   <html>
-	       <head><title>The LearningOnline Network with CAPA Logout</title>
-	       $switch
-	       </head>
-	       $bodytag
-	       $windowinfo
-	       </body>
-	       </html>
-ENDDOCUMENT
+    $r->print($start_page.$windowinfo.$end_page);
 
     &Apache::lonnet::flushcourselogs();
     return OK;

--albertel1144276796--