[LON-CAPA-cvs] cvs: loncom /interface lonpreferences.pm
matthew
lon-capa-cvs@mail.lon-capa.org
Sat, 21 Feb 2004 01:31:04 -0000
This is a MIME encoded message
--matthew1077327064
Content-Type: text/plain
matthew Fri Feb 20 20:31:04 2004 EDT
Modified files:
/loncom/interface lonpreferences.pm
Log:
Interface overhaul. Now uses lonhtmlcommon::breadcrumbs. Many other
changes to the interface.
--matthew1077327064
Content-Type: text/plain
Content-Disposition: attachment; filename="matthew-20040220203104.txt"
Index: loncom/interface/lonpreferences.pm
diff -u loncom/interface/lonpreferences.pm:1.34 loncom/interface/lonpreferences.pm:1.35
--- loncom/interface/lonpreferences.pm:1.34 Wed Jan 14 10:51:07 2004
+++ loncom/interface/lonpreferences.pm Fri Feb 20 20:31:04 2004
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Preferences
#
-# $Id: lonpreferences.pm,v 1.34 2004/01/14 15:51:07 www Exp $
+# $Id: lonpreferences.pm,v 1.35 2004/02/21 01:31:04 matthew Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -112,8 +112,6 @@
('environment',['languages']);
my $language=$userenv{'languages'};
- my $bodytag=&Apache::loncommon::bodytag(
- 'Change Your Language Preferences');
my $pref=&mt('Preferred language');
my %langchoices=('' => 'No language preference');
foreach (&Apache::loncommon::languageids()) {
@@ -125,14 +123,11 @@
my $selectionbox=&Apache::loncommon::select_form($language,'language',
%langchoices);
$r->print(<<ENDLSCREEN);
-<html>
-$bodytag
-
<form name="server" action="/adm/preferences" method="post">
<input type="hidden" name="action" value="verify_and_change_languages" />
<br />$pref: $selectionbox
ENDLSCREEN
- $r->print('<br /><input type="submit" value="'.&mt('Change').'" /></form></body></html>');
+ $r->print('<br /><input type="submit" value="'.&mt('Change').'" />');
}
@@ -153,14 +148,9 @@
&Apache::lonnet::delenv('environment\.languages');
$message='Reset preferred language';
}
- my $bodytag=&Apache::loncommon::bodytag(
- 'Change Your Language Preferences');
$r->print(<<ENDVCSCREEN);
-<html>
-$bodytag
</p>
$message
-</body></html>
ENDVCSCREEN
}
@@ -176,12 +166,7 @@
('environment',['screenname','nickname']);
my $screenname=$userenv{'screenname'};
my $nickname=$userenv{'nickname'};
- my $bodytag=&Apache::loncommon::bodytag(
- 'Change Your Nickname and Anonymous Screen Name');
$r->print(<<ENDSCREEN);
-<html>
-$bodytag
-
<form name="server" action="/adm/preferences" method="post">
<input type="hidden" name="action" value="verify_and_change_screenname" />
<br />New screenname (shown if you post anonymously):
@@ -190,8 +175,6 @@
<input type="text" size="20" value="$nickname" name="nickname" />
<input type="submit" value="Change" />
</form>
-</body>
-</html>
ENDSCREEN
}
@@ -226,14 +209,9 @@
$message.='Reset nickname';
}
- my $bodytag=&Apache::loncommon::bodytag(
- 'Change Your Nickname and Anonymous Screen Name');
$r->print(<<ENDVCSCREEN);
-<html>
-$bodytag
</p>
$message
-</body></html>
ENDVCSCREEN
}
@@ -249,8 +227,6 @@
my $msgforward=$userenv{'msgforward'};
my $notification=$userenv{'notification'};
my $critnotification=$userenv{'critnotification'};
- my $bodytag=&Apache::loncommon::bodytag(
- 'Change Your Message Forwarding and Notification');
my $forwardingHelp = Apache::loncommon::help_open_topic("Prefs_Forwarding",
"What are forwarding ".
"and notification ".
@@ -259,8 +235,6 @@
"What are critical messages");
$r->print(<<ENDMSG);
-<html>
-$bodytag
$forwardingHelp <br />
<form name="server" action="/adm/preferences" method="post">
<input type="hidden" name="action" value="verify_and_change_msgforward" />
@@ -272,8 +246,6 @@
<input type="text" size="40" value="$critnotification" name="critnotification" />$criticalMessageHelp<hr />
<input type="submit" value="Change" />
</form>
-</body>
-</html>
ENDMSG
}
@@ -327,14 +299,9 @@
&Apache::lonnet::delenv('environment\.critnotification');
$message.='Reset critical message notification<br />';
}
- my $bodytag=&Apache::loncommon::bodytag(
- 'Change Your Message Forwarding and Notifications');
$r->print(<<ENDVCMSG);
-<html>
-$bodytag
</p>
$message
-</body></html>
ENDVCMSG
}
@@ -344,9 +311,6 @@
sub colorschanger {
my $r = shift;
- my $bodytag=&Apache::loncommon::bodytag(
- 'Change Color Scheme for Current Role Type','',
- 'onUnload="pclose();"');
# figure out colors
my $function='student';
if ($ENV{'request.role'}=~/^(cc|in|ta|ep)/) {
@@ -379,7 +343,6 @@
}
my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
$r->print(<<ENDCOL);
-<html>
<script>
function pclose() {
@@ -406,7 +369,6 @@
</script>
-$bodytag
<form name="parmform">
<input type="hidden" name="pres_marker" />
<input type="hidden" name="pres_type" />
@@ -420,8 +382,6 @@
<input type="submit" value="Change Custom Colors" />
<input type="submit" name="resetall" value="Reset All Colors to Default" />
</form>
-</body>
-</html>
ENDCOL
}
@@ -462,18 +422,12 @@
$message.='Reset '.$colortypes{$item}.'<br />';
}
}
- my $bodytag=&Apache::loncommon::bodytag(
- 'Change Color Scheme for Current Role Type');
$r->print(<<ENDVCCOL);
-<html>
-$bodytag
</p>
$message
<form name="client" action="/adm/preferences" method="post">
<input type="hidden" name="action" value="changecolors" />
-<input type="submit" value="Revise color scheme again" />
</form>
-</body></html>
ENDVCCOL
}
@@ -519,12 +473,7 @@
my $jsh=Apache::File->new($include."/londes.js");
$r->print(<$jsh>);
}
- my $bodytag=&Apache::loncommon::bodytag('Change Password','',
- 'onLoad="init();"');
$r->print(<<ENDFORM);
-</head>
-$bodytag
-
<script language="JavaScript">
function send() {
@@ -706,118 +655,190 @@
$r->send_http_header;
return OK if $r->header_only;
#
- if ($ENV{'form.action'} eq 'changepass') {
- &passwordchanger($r);
- } elsif ($ENV{'form.action'} eq 'verify_and_change_pass') {
- &verify_and_change_password($r);
- } elsif ($ENV{'form.action'} eq 'changescreenname') {
- &screennamechanger($r);
- } elsif ($ENV{'form.action'} eq 'verify_and_change_screenname') {
- &verify_and_change_screenname($r);
- } elsif ($ENV{'form.action'} eq 'changemsgforward') {
- &msgforwardchanger($r);
- } elsif ($ENV{'form.action'} eq 'verify_and_change_msgforward') {
- &verify_and_change_msgforward($r);
- } elsif ($ENV{'form.action'} eq 'changecolors') {
- &colorschanger($r);
- } elsif ($ENV{'form.action'} eq 'verify_and_change_colors') {
- &verify_and_change_colors($r);
- } elsif ($ENV{'form.action'} eq 'changelanguages') {
- &languagechanger($r);
- } elsif ($ENV{'form.action'} eq 'verify_and_change_languages') {
- &verify_and_change_languages($r);
- } elsif ($ENV{'form.action'} eq 'debugtoggle') {
- if (($ENV{'user.name'} eq 'albertel' ) ||
- ($ENV{'user.name'} eq 'kortemey' ) ||
- ($ENV{'user.name'} eq 'korte')) {
- if ($ENV{'user.debug'}) {
- &Apache::lonnet::delenv('user\.debug');
- } else {
- &Apache::lonnet::appenv('user.debug' => 1);
- }
- }
- } else {
- my %help=();
- foreach ('Change_Colors','Change_Password',
- 'Prefs_Screen_Name_Nickname','Prefs_Forwarding') {
- $help{$_}=&Apache::loncommon::help_open_topic($_);
- }
- $r->print(<<ENDHEADER);
+ &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
+ ['action']);
+ #
+ &Apache::lonhtmlcommon::clear_breadcrumbs();
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ({href => '/adm/preferences',
+ text => 'Set User Preferences'});
+
+ my @Options;
+ # Determine current authentication method
+ my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
+ if ($currentauth =~ /^(unix|internal):/) {
+ push (@Options,({ action => 'changepass',
+ linktext => 'Change password',
+ href => '/adm/preferences',
+ help => 'Change_Password',
+ subroutine => \&passwordchanger,
+ breadcrumb =>
+ { href => '/adm/preferences?action=changepass',
+ text => 'Change Password'},
+ },
+ { action => 'verify_and_change_pass',
+ subroutine => \&verify_and_change_password,
+ breadcrumb =>
+ { href =>'/adm/preferences?action=changepass',
+ text => 'Change Password'},
+ printmenu => 'yes',
+ }));
+ }
+ push (@Options,({ action => 'changescreenname',
+ linktext => 'Change Screen Name',
+ href => '/adm/preferences',
+ help => 'Prefs_Screen_Name_Nickname',
+ subroutine => \&screennamechanger,
+ breadcrumb =>
+ { href => '/adm/preferences?action=changescreenname',
+ text => 'Change Screen Name'},
+ },
+ { action => 'verify_and_change_screenname',
+ subroutine => \&verify_and_change_screenname,
+ breadcrumb =>
+ { href => '/adm/preferences?action=changescreenname',
+ text => 'Change Screen Name'},
+ printmenu => 'yes',
+ }));
+
+ push (@Options,({ action => 'changemsgforward',
+ linktext => 'Change Message Forwarding',
+ text => 'and Notification Addresses',
+ href => '/adm/preferences',
+ help => 'Prefs_Forwarding',
+ breadcrumb =>
+ { href => '/adm/preferences?action=changemsgforward',
+ text => 'Change Message Forwarding'},
+ subroutine => \&msgforwardchanger,
+ },
+ { action => 'verify_and_change_msgforward',
+ breadcrumb =>
+ { href => '/adm/preferences?action=changemsgforward',
+ text => 'Change Message Forwarding'},
+ printmenu => 'yes',
+ subroutine => \&verify_and_change_msgforward }));
+ my $aboutmeaction=
+ '/adm/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/aboutme';
+ push (@Options,{ action => 'none',
+ linktext =>
+ q{Edit the 'About Me' personal information screen},
+ href => $aboutmeaction});
+ push (@Options,({ action => 'changecolors',
+ linktext => 'Change Color Scheme',
+ href => '/adm/preferences',
+ help => 'Change_Colors',
+ breadcrumb =>
+ { href => '/adm/preferences?action=changecolors',
+ text => 'Change Colors'},
+ subroutine => \&colorschanger,
+ },
+ { action => 'verify_and_change_colors',
+ breadcrumb =>
+ { href => '/adm/preferences?action=changecolors',
+ text => 'Change Colors'},
+ printmenu => 'yes',
+ subroutine => \&verify_and_change_colors,
+ }));
+ push (@Options,({ action => 'changelanguages',
+ linktext => 'Change Language Prefences',
+ href => '/adm/preferences',
+ breadcrumb=>
+ { href => '/adm/preferences?action=changelanguages',
+ text => 'Change Language'},
+ subroutine => \&languagechanger,
+ },
+ { action => 'verify_and_change_languages',
+ breadcrumb=>
+ {href => '/adm/preferences?action=changelanguages',
+ text => 'Change Language'},
+ printmenu => 'yes',
+ subroutine=>\&verify_and_change_languages, }
+ ));
+ if ($ENV{'user.name'} =~ /^(albertel|koretemey|korte|hallmat3|turtle)$/) {
+ push (@Options,({ action => 'debugtoggle',
+ printmenu => 'yes',
+ subroutine => \&toggle_debug,
+ }));
+ }
+ $r->print(<<ENDHEADER);
<html>
<head>
<title>LON-CAPA Preferences</title>
</head>
ENDHEADER
- $r->print(&Apache::loncommon::bodytag('Change Your Preferences'));
- # Determine current authentication method
- my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
- if ($currentauth =~ /^(unix|internal):/) {
- $r->print(<<ENDPASSWORDFORM);
-<form name="client" action="/adm/preferences" method="post">
-<input type="hidden" name="action" value="changepass" />
-<input type="submit" value="Change password" />
-$help{'Change_Password'}
-</form>
-ENDPASSWORDFORM
+ my $call = undef;
+ my $printmenu = 'yes';
+ foreach my $option (@Options) {
+ if ($option->{'action'} eq $ENV{'form.action'}) {
+ &Apache::lonnet::logthis('got action '.$option->{'action'});
+ $call = $option->{'subroutine'};
+ $printmenu = $option->{'printmenu'};
+ if (exists($option->{'breadcrumb'})) {
+ &Apache::lonhtmlcommon::add_breadcrumb
+ ($option->{'breadcrumb'});
+ }
}
-# Change screen name
- $r->print(<<ENDSCREENNAMEFORM);
-<form name="client" action="/adm/preferences" method="post">
-<input type="hidden" name="action" value="changescreenname" />
-<input type="submit"
-value="Change nickname and anonymous discussion screen name" />
-$help{'Prefs_Screen_Name_Nickname'}
-</form>
-ENDSCREENNAMEFORM
- $r->print(<<ENDMSGFORWARDFORM);
-<form name="client" action="/adm/preferences" method="post">
-<input type="hidden" name="action" value="changemsgforward" />
-<input type="submit" value="Change message forwarding and notification addresses" />
-$help{'Prefs_Forwarding'}
-</form>
-ENDMSGFORWARDFORM
-# The "about me" page
- my $aboutmeaction=
- '/adm/'.$ENV{'user.domain'}.'/'.$ENV{'user.name'}.'/aboutme';
- $r->print(<<ENDABOUTME);
-<form name="client" action="$aboutmeaction" method="post">
-<input type="hidden" name="action" value="changescreenname" />
-<input type="submit" value="Edit the 'About Me' personal information screen" />
-</form>
-ENDABOUTME
- $r->print(<<ENDCOLORFORM);
-<form name="client" action="/adm/preferences" method="post">
-<input type="hidden" name="action" value="changecolors" />
-<input type="submit" value="Change color scheme" />
-$help{'Change_Colors'}
-</form>
-ENDCOLORFORM
-
- $r->print(<<ENDLANGUAGES);
-<form name="client" action="/adm/preferences" method="post">
-<input type="hidden" name="action" value="changelanguages" />
-<input type="submit" value="Change language preferences" />
-</form>
-ENDLANGUAGES
-
- if (($ENV{'user.name'} eq 'albertel' ) ||
- ($ENV{'user.name'} eq 'kortemey' ) ||
- ($ENV{'user.name'} eq 'korte')) {
- $r->print(<<ENDDEBUG);
-<form name="client" action="/adm/preferences" method="post">
-<input type="hidden" name="action" value="debugtoggle" />
-<input type="submit" value="Toggle Debug" />
-Current Debug status is -$ENV{'user.debug'}-.
-</form>
-ENDDEBUG
- }
- # Other preference setting code should be added here
+ }
+ $r->print(&Apache::loncommon::bodytag('Change Preferences'));
+ $r->print(&Apache::lonhtmlcommon::breadcrumbs
+ (undef,'Change Preferences'));
+ if (defined($call)) {
+ $call->($r);
+ }
+ if ($printmenu eq 'yes') {
+ my $optionlist = '<table cellpadding="5">';
+ if ($ENV{'user.name'} =~
+ /^(albertel|koretemey|korte|hallmat3|turtle)$/
+ ) {
+ push (@Options,({ action => 'debugtoggle',
+ linktext => 'Toggle Debug Messages',
+ text => 'Current Debug status is -'.
+ $ENV{'user.debug'}.'-.',
+ href => '/adm/preferences',
+ printmenu => 'yes',
+ subroutine => \&toggle_debug,
+ }));
+ }
+ foreach my $option(@Options) {
+ my $optiontext = '';
+ if (exists($option->{'href'})) {
+ $optiontext .=
+ '<a href="'.$option->{'href'}.
+ '?action='.$option->{'action'}.'">'.
+ $option->{'linktext'}.'</a>';
+ }
+ if (exists($option->{'text'})) {
+ $optiontext .= ' '.$option->{'text'};
+ }
+ if ($optiontext ne '') {
+ $optiontext = '<font size="+1">'.$optiontext.'</font>';
+ my $helplink = ' ';
+ if (exists($option->{'help'})) {
+ $helplink = &Apache::loncommon::help_open_topic
+ ($option->{'help'});
+ }
+ $optionlist .= '<tr>'.
+ '<td>'.$helplink.'</td>'.
+ '<td>'.$optiontext.'</td>'.
+ '</tr>';
+ }
+ }
+ $optionlist .= '</table>';
+ $r->print($optionlist);
}
$r->print(<<ENDFOOTER);
</body>
</html>
ENDFOOTER
return OK;
+}
+
+sub toggle_debug {
+ if ($ENV{'user.debug'}) {
+ &Apache::lonnet::delenv('user\.debug');
+ } else {
+ &Apache::lonnet::appenv('user.debug' => 1);
+ }
}
1;
--matthew1077327064--