Annotation of loncom/interface/lonpreferences.pm, revision 1.157
1.1 www 1: # The LearningOnline Network
2: # Preferences
3: #
1.157 ! bisitz 4: # $Id: lonpreferences.pm,v 1.156 2009/05/04 19:35:31 tempelho Exp $
1.2 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
1.3 matthew 28: # This package uses the "londes.js" javascript code.
29: #
30: # TODOs that have to be completed:
31: # interface with lonnet to change the password
32:
1.1 www 33: package Apache::lonpreferences;
34:
35: use strict;
1.86 albertel 36: use LONCAPA;
1.1 www 37: use Apache::Constants qw(:common);
1.3 matthew 38: use Apache::File;
39: use Crypt::DES;
40: use DynaLoader; # for Crypt::DES version
1.4 matthew 41: use Apache::loncommon();
1.23 matthew 42: use Apache::lonhtmlcommon();
1.32 www 43: use Apache::lonlocal;
1.59 albertel 44: use Apache::lonnet;
1.95 albertel 45: use LONCAPA();
1.3 matthew 46:
47: #
48: # Write lonnet::passwd to do the call below.
49: # Use:
50: # my $answer=reply("encrypt:passwd:$udom:$uname:$upass",$tryserver);
51: #
52: ##################################################
53: # password associated functions #
54: ##################################################
55: sub des_keys {
1.4 matthew 56: # Make a new key for DES encryption.
1.36 www 57: # Each key has two parts which are returned separately.
1.4 matthew 58: # Please note: Each key must be passed through the &hex function
59: # before it is output to the web browser. The hex versions cannot
60: # be used to decrypt.
1.3 matthew 61: my @hexstr=('0','1','2','3','4','5','6','7',
62: '8','9','a','b','c','d','e','f');
63: my $lkey='';
64: for (0..7) {
65: $lkey.=$hexstr[rand(15)];
66: }
67: my $ukey='';
68: for (0..7) {
69: $ukey.=$hexstr[rand(15)];
70: }
71: return ($lkey,$ukey);
72: }
73:
74: sub des_decrypt {
75: my ($key,$cyphertext) = @_;
76: my $keybin=pack("H16",$key);
77: my $cypher;
78: if ($Crypt::DES::VERSION>=2.03) {
79: $cypher=new Crypt::DES $keybin;
80: } else {
81: $cypher=new DES $keybin;
82: }
83: my $plaintext=
84: $cypher->decrypt(unpack("a8",pack("H16",substr($cyphertext,0,16))));
85: $plaintext.=
86: $cypher->decrypt(unpack("a8",pack("H16",substr($cyphertext,16,16))));
1.4 matthew 87: $plaintext=substr($plaintext,1,ord(substr($plaintext,0,1)) );
1.3 matthew 88: return $plaintext;
89: }
90:
1.4 matthew 91: ################################################################
92: # Handler subroutines #
93: ################################################################
1.9 matthew 94:
95: ################################################################
1.28 www 96: # Language Change Subroutines #
97: ################################################################
1.44 www 98:
99: sub wysiwygchanger {
100: my $r = shift;
1.126 droeschl 101: Apache::lonhtmlcommon::add_breadcrumb(
102: { href => '/adm/preferences?action=changewysiwyg',
103: text => 'Change WYSIWYG Preferences'});
1.147 schafran 104: $r->print(Apache::loncommon::start_page('Content Display Settings'));
1.126 droeschl 105: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change WYSIWYG Preferences'));
106:
1.44 www 107: my %userenv = &Apache::lonnet::get
108: ('environment',['wysiwygeditor']);
1.78 albertel 109: my $onselect='checked="checked"';
1.44 www 110: my $offselect='';
1.77 albertel 111: if ($userenv{'wysiwygeditor'} eq 'on') {
1.44 www 112: $onselect='';
1.78 albertel 113: $offselect='checked="checked"';
1.44 www 114: }
115: my $switchoff=&mt('Disable WYSIWYG editor');
116: my $switchon=&mt('Enable WYSIWYG editor');
1.124 www 117: my $warning='';
118: if ($env{'user.adv'}) {
119: $warning.="<p>".&mt("The WYSIWYG editor only supports simple HTML and is in many cases unsuited for advanced authoring. In a number of cases, it may destroy advanced authoring involving LaTeX and script function calls.")."</p>";
120: }
1.44 www 121: $r->print(<<ENDLSCREEN);
1.88 albertel 122: <form name="prefs" action="/adm/preferences" method="post">
1.44 www 123: <input type="hidden" name="action" value="set_wysiwyg" />
1.124 www 124: $warning
1.44 www 125: <br />
1.65 albertel 126: <label><input type="radio" name="wysiwyg" value="off" $onselect /> $switchoff</label><br />
127: <label><input type="radio" name="wysiwyg" value="on" $offselect /> $switchon</label>
1.44 www 128: ENDLSCREEN
1.136 schafran 129: $r->print('<br /><input type="submit" value="'.&mt('Save').'" />');
1.44 www 130: }
131:
132:
133: sub verify_and_change_wysiwyg {
134: my $r = shift;
1.59 albertel 135: my $newsetting=$env{'form.wysiwyg'};
1.44 www 136: &Apache::lonnet::put('environment',{'wysiwygeditor' => $newsetting});
1.116 raeburn 137: &Apache::lonnet::appenv({'environment.wysiwygeditor' => $newsetting});
1.152 www 138: &print_main_menu($r,'<p>'.&Apache::lonhtmlcommon::confirm_success(&mt('Setting WYSIWYG editor to:').' '
139: .&mt($newsetting)).'</p>');
1.44 www 140: }
141:
142: ################################################################
143: # Language Change Subroutines #
144: ################################################################
1.28 www 145: sub languagechanger {
146: my $r = shift;
1.126 droeschl 147:
148: Apache::lonhtmlcommon::add_breadcrumb(
149: { href => '/adm/preferences?action=changelanguages',
1.127 droeschl 150: text => 'Change Language'});
1.147 schafran 151: $r->print(Apache::loncommon::start_page('Content Display Settings'));
1.126 droeschl 152: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Language'));
1.59 albertel 153: my $user = $env{'user.name'};
154: my $domain = $env{'user.domain'};
1.28 www 155: my %userenv = &Apache::lonnet::get
1.32 www 156: ('environment',['languages']);
1.29 www 157: my $language=$userenv{'languages'};
1.32 www 158:
1.33 www 159: my $pref=&mt('Preferred language');
160: my %langchoices=('' => 'No language preference');
161: foreach (&Apache::loncommon::languageids()) {
162: if (&Apache::loncommon::supportedlanguagecode($_)) {
163: $langchoices{&Apache::loncommon::supportedlanguagecode($_)}
164: = &Apache::loncommon::plainlanguagedescription($_);
165: }
166: }
167: my $selectionbox=&Apache::loncommon::select_form($language,'language',
168: %langchoices);
1.28 www 169: $r->print(<<ENDLSCREEN);
1.88 albertel 170: <form name="prefs" action="/adm/preferences" method="post">
1.28 www 171: <input type="hidden" name="action" value="verify_and_change_languages" />
1.33 www 172: <br />$pref: $selectionbox
1.28 www 173: ENDLSCREEN
1.136 schafran 174: $r->print('<br /><input type="submit" value="'.&mt('Save').'" />');
1.28 www 175: }
176:
177:
178: sub verify_and_change_languages {
179: my $r = shift;
1.59 albertel 180: my $user = $env{'user.name'};
181: my $domain = $env{'user.domain'};
1.28 www 182: # Screenname
1.59 albertel 183: my $newlanguage = $env{'form.language'};
1.28 www 184: $newlanguage=~s/[^\-\w]//g;
185: my $message='';
186: if ($newlanguage) {
1.29 www 187: &Apache::lonnet::put('environment',{'languages' => $newlanguage});
1.116 raeburn 188: &Apache::lonnet::appenv({'environment.languages' => $newlanguage});
1.152 www 189: $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set new preferred languages to ').'<tt>"'.$newlanguage.'"</tt>.');
1.28 www 190: } else {
1.29 www 191: &Apache::lonnet::del('environment',['languages']);
1.139 raeburn 192: &Apache::lonnet::delenv('environment.languages');
1.152 www 193: $message=&Apache::lonhtmlcommon::confirm_success(&mt('Reset preferred language.'));
1.28 www 194: }
1.132 raeburn 195: &Apache::loncommon::flush_langs_cache($user,$domain);
1.152 www 196: &print_main_menu($r, $message);
1.28 www 197: }
198:
1.50 albertel 199: ################################################################
1.54 albertel 200: # Tex Engine Change Subroutines #
201: ################################################################
202: sub texenginechanger {
203: my $r = shift;
1.126 droeschl 204: Apache::lonhtmlcommon::add_breadcrumb(
205: { href => '/adm/preferences?action=changetexenginepref',
206: text => 'Change How Math Equations Are Displayed'});
1.147 schafran 207: $r->print(Apache::loncommon::start_page('Content Display Settings'));
1.126 droeschl 208: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change How Math Equations Are Displayed'));
1.59 albertel 209: my $user = $env{'user.name'};
210: my $domain = $env{'user.domain'};
1.54 albertel 211: my %userenv = &Apache::lonnet::get('environment',['texengine']);
212: my $texengine=$userenv{'texengine'};
213:
1.69 albertel 214: my %mathchoices=('' => 'Default',
1.123 bisitz 215: 'tth' => 'tth (TeX to HTML)',
1.64 albertel 216: #'ttm' => 'TeX to MathML',
1.54 albertel 217: 'jsMath' => 'jsMath',
1.123 bisitz 218: 'mimetex' => 'mimetex (Convert to Images)'
1.54 albertel 219: );
220: my $selectionbox=&Apache::loncommon::select_form($texengine,'texengine',
221: %mathchoices);
1.67 albertel 222: my $jsMath_start=&Apache::lontexconvert::jsMath_header();
1.123 bisitz 223: my %lt=&Apache::lonlocal::texthash(
224: 'headline' => 'Change Math Preferences',
225: 'preftxt' => 'Preferred method to display Math',
1.136 schafran 226: 'change' => 'Save',
1.123 bisitz 227: 'exmpl' => 'Examples',
228: 'jsmath' => 'jsMath:',
229: 'tth' => 'tth (TeX to HTML):',
230: 'mimetex' => 'mimetex (Convert to Images):',
231: );
232:
1.54 albertel 233: $r->print(<<ENDLSCREEN);
1.123 bisitz 234: <h2>$lt{'headline'}</h2>
1.88 albertel 235: <form name="prefs" action="/adm/preferences" method="post">
1.54 albertel 236: <input type="hidden" name="action" value="verify_and_change_texengine" />
1.123 bisitz 237: <p>
1.136 schafran 238: $lt{'preftxt'}: $selectionbox
239: <br />
240: <input type="submit" value="$lt{'change'}" />
1.123 bisitz 241: </p>
1.54 albertel 242: </form>
1.123 bisitz 243: <br />
244: <hr />
245: $lt{'exmpl'}
246:
247: <h3>$lt{'jsmath'}</h3>
248: <p>
1.67 albertel 249: $jsMath_start
1.148 bisitz 250: <script type="text/javascript" language="JavaScript">
1.54 albertel 251: if (jsMath.nofonts == 1) {
252: document.writeln
1.123 bisitz 253: ('<div style="padding: 10; border-style: solid; border-width:3;'
1.54 albertel 254: +' border-color: #DD0000; background-color: #FFF8F8; width: 75%; text-align: left">'
255: +'<small><font color="#AA0000"><b>Warning:</b> '
256: +'It looks like you don\\\'t have the TeX math fonts installed. '
257: +'The jsMath example on this page may not look right without them. '
258: +'The <a href="http://www.math.union.edu/locate/jsMath/" target="_blank"> '
259: +'jsMath Home Page</a> has information on how to download the '
260: +'needed fonts. In the meantime, jsMath will do the best it can '
261: +'with the fonts you have, but it may not be pretty and some equations '
262: +'may not be rendered correctly. '
1.123 bisitz 263: +'</font></small></div>');
1.54 albertel 264: }
265: </script>
1.122 www 266: <iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=jsMath" width="400" height="120"></iframe>
1.123 bisitz 267: </p>
1.54 albertel 268:
1.123 bisitz 269: <h3>$lt{'mimetex'}</h3>
270: <p>
271: <iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=mimetex" width="400" height="100"></iframe>
1.67 albertel 272: </p>
1.123 bisitz 273:
274: <h3>$lt{'tth'}</h3>
275: <p>
276: <iframe src="/res/adm/pages/math_example.tex?inhibitmenu=yes&texengine=tth" width="400" height="200"></iframe>
1.67 albertel 277: </p>
1.54 albertel 278: ENDLSCREEN
1.59 albertel 279: if ($env{'environment.texengine'} ne 'jsMath') {
1.148 bisitz 280: $r->print('<script type="text/javascript" language="JavaScript">jsMath.Process()</script>');
1.55 albertel 281: }
1.54 albertel 282: }
283:
284:
285: sub verify_and_change_texengine {
286: my $r = shift;
1.59 albertel 287: my $user = $env{'user.name'};
288: my $domain = $env{'user.domain'};
1.54 albertel 289: # Screenname
1.59 albertel 290: my $newtexengine = $env{'form.texengine'};
1.54 albertel 291: $newtexengine=~s/[^\-\w]//g;
1.56 albertel 292: if ($newtexengine eq 'ttm') {
1.116 raeburn 293: &Apache::lonnet::appenv({'browser.mathml' => 1});
1.56 albertel 294: } else {
1.59 albertel 295: if ($env{'environment.texengine'} eq 'ttm') {
1.116 raeburn 296: &Apache::lonnet::appenv({'browser.mathml' => 0});
1.56 albertel 297: }
298: }
1.54 albertel 299: my $message='';
300: if ($newtexengine) {
301: &Apache::lonnet::put('environment',{'texengine' => $newtexengine});
1.116 raeburn 302: &Apache::lonnet::appenv({'environment.texengine' => $newtexengine});
1.152 www 303: $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set new preferred math display to ').'<tt>"'.$newtexengine.'"</tt>.');
1.54 albertel 304: } else {
305: &Apache::lonnet::del('environment',['texengine']);
1.139 raeburn 306: &Apache::lonnet::delenv('environment.texengine');
1.152 www 307: $message=&Apache::lonhtmlcommon::confirm_success(&mt('Reset preferred math display.'));
1.54 albertel 308: }
1.152 www 309: &print_main_menu($r, $message);
1.54 albertel 310: }
311:
312: ################################################################
1.50 albertel 313: # Roles Page Preference Change Subroutines #
314: ################################################################
315: sub rolesprefchanger {
316: my $r = shift;
1.96 albertel 317: my $role = ($env{'user.adv'} ? 'Role' : 'Course');
318: my $lc_role = ($env{'user.adv'} ? 'role' : 'course');
1.59 albertel 319: my $user = $env{'user.name'};
320: my $domain = $env{'user.domain'};
1.50 albertel 321: my %userenv = &Apache::lonnet::get
322: ('environment',['recentroles','recentrolesn']);
1.126 droeschl 323: Apache::lonhtmlcommon::add_breadcrumb(
324: { href => '/adm/preferences?action=changerolespref',
325: text => 'Change '.$role.' Page Pref'});
1.147 schafran 326: $r->print(Apache::loncommon::start_page('Content Display Settings'));
1.126 droeschl 327: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change '.$role.' Page Pref'));
1.50 albertel 328: my $hotlist_flag=$userenv{'recentroles'};
329: my $hotlist_n=$userenv{'recentrolesn'};
330: my $checked;
331: if ($hotlist_flag) {
332: $checked = 'checked="checked"';
333: }
334:
335: if (!$hotlist_n) { $hotlist_n=3; }
336: my $options;
337: for (my $i=1; $i<10; $i++) {
338: my $select;
339: if ($hotlist_n == $i) { $select = 'selected="selected"'; }
340: $options .= "<option $select>$i</option>\n";
341: }
342:
1.89 albertel 343: # Get list of recent roles and display with checkbox in front
344: my $roles_check_list = '';
345: my $role_key='';
346: if ($env{'environment.recentroles'}) {
347: my %recent_roles =
348: &Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'});
1.91 albertel 349: my %frozen_roles =
350: &Apache::lonhtmlcommon::get_recent_frozen('roles',$env{'environment.recentrolesn'});
1.89 albertel 351:
1.93 albertel 352: my %role_text = &rolespref_get_role_text([keys(%recent_roles)]);
1.92 albertel 353: my @sorted_roles = sort {$role_text{$a} cmp $role_text{$b}} keys(%role_text);
354:
1.89 albertel 355: $roles_check_list .=
356: &Apache::loncommon::start_data_table().
357: &Apache::loncommon::start_data_table_header_row().
1.96 albertel 358: "<th>".&mt('Freeze '.$role)."</th>".
359: "<th>".&mt($role)."</td>".
1.89 albertel 360: &Apache::loncommon::end_data_table_header_row().
361: "\n";
362: my $count;
1.92 albertel 363: foreach $role_key (@sorted_roles) {
1.89 albertel 364: my $checked = "";
365: my $value = $recent_roles{$role_key};
1.91 albertel 366: if ($frozen_roles{$role_key}) {
1.89 albertel 367: $checked = "checked=\"checked\"";
368: }
369: $count++;
370: $roles_check_list .=
371: &Apache::loncommon::start_data_table_row().
372: '<td class="LC_table_cell_checkbox">'.
373: "<input type=\"checkbox\" $checked name=\"freezeroles\"".
374: " id=\"freezeroles$count\" value=\"$role_key\" /></td>".
375: "<td><label for=\"freezeroles$count\">".
1.92 albertel 376: "$role_text{$role_key}</label></td>".
1.89 albertel 377: &Apache::loncommon::end_data_table_row(). "\n";
378: }
379: $roles_check_list .= "</table>\n";
380: }
381:
382: $r->print('
1.96 albertel 383: <p>'.&mt('Some LON-CAPA users have a long list of '.$lc_role.'s. The Recent '.$role.'s Hotlist feature keeps track of the last N '.$lc_role.'s which have been visited and places a table of these at the top of the '.$lc_role.'s page. People with very few '.$lc_role.'s should leave this feature disabled.').'
1.50 albertel 384: </p>
1.89 albertel 385: <form name="prefs" action="/adm/preferences" method="POST">
1.50 albertel 386: <input type="hidden" name="action" value="verify_and_change_rolespref" />
1.96 albertel 387: <br /><label>'.&mt('Enable Recent '.$role.'s Hotlist:').'
1.89 albertel 388: <input type="checkbox" '.$checked.' name="recentroles" value="true" /></label>
1.96 albertel 389: <br />'.&mt('Number of '.$role.'s in Hotlist:').'
1.50 albertel 390: <select name="recentrolesn" size="1">
1.89 albertel 391: '.$options.'
1.50 albertel 392: </select>
1.96 albertel 393: <p>'.&mt('This list below can be used to <q>freeze</q> '.$lc_role.'s on your screen. Those marked as frozen will not be removed from the list, even if they have not been used recently.').'
1.89 albertel 394: </p>
395: '.$roles_check_list.'
1.50 albertel 396: <br />
1.136 schafran 397: <input type="submit" value="'.&mt('Save').'" />
1.89 albertel 398: </form>');
1.50 albertel 399: }
400:
1.92 albertel 401: sub rolespref_get_role_text {
402: # Get a line of text for each role
403: my ($roles) = @_;
404: my %roletext = ();
405:
406: foreach my $item (@$roles) {
407: # get course information
408: my ($role,$rest) = split(/\./, $item);
1.93 albertel 409: my $trole = "";
410: $trole = &Apache::lonnet::plaintext($role);
1.92 albertel 411: my ($tdomain,$other,$tsection)= split(/\//,Apache::lonnet::declutter($rest));
412: my $tother = '-';
1.93 albertel 413: if ($role =~ /^(cc|st|in|ta|ep|cr)/ ) {
1.92 albertel 414: my %newhash=&Apache::lonnet::coursedescription($tdomain."_".$other);
415: $tother = " - ".$newhash{'description'};
416: } elsif ($role =~ /dc/) {
417: $tother = "";
418: } else {
419: $tother = " - $other";
420: }
421:
422: my $section="";
423: if ($tsection) {
424: $section = " - Section/Group: $tsection";
425: }
426: $roletext{$item} = $tdomain." - ".$trole.$tother.$section;
427: }
428: return %roletext;
429: }
430:
1.50 albertel 431: sub verify_and_change_rolespref {
432: my $r = shift;
1.96 albertel 433: my $role = ($env{'user.adv'} ? 'Role' : 'Course');
1.59 albertel 434: my $user = $env{'user.name'};
435: my $domain = $env{'user.domain'};
1.50 albertel 436: # Recent Roles Hotlist Flag
1.59 albertel 437: my $hotlist_flag = $env{'form.recentroles'};
438: my $hotlist_n = $env{'form.recentrolesn'};
1.89 albertel 439: my $message='<hr />';
1.50 albertel 440: if ($hotlist_flag) {
441: &Apache::lonnet::put('environment',{'recentroles' => $hotlist_flag});
1.116 raeburn 442: &Apache::lonnet::appenv({'environment.recentroles' => $hotlist_flag});
1.96 albertel 443: $message=&mt('Recent '.$role.'s Hotlist is Enabled');
1.50 albertel 444: } else {
445: &Apache::lonnet::del('environment',['recentroles']);
1.139 raeburn 446: &Apache::lonnet::delenv('environment.recentroles');
1.96 albertel 447: $message=&mt('Recent '.$role.'s Hotlist is Disabled');
1.50 albertel 448: }
449: if ($hotlist_n) {
450: &Apache::lonnet::put('environment',{'recentrolesn' => $hotlist_n});
1.116 raeburn 451: &Apache::lonnet::appenv({'environment.recentrolesn' => $hotlist_n});
1.50 albertel 452: if ($hotlist_flag) {
1.90 albertel 453: $message.="<br />".
1.96 albertel 454: &mt('Display [_1] Most Recent '.$role.'s',$hotlist_n)."\n";
1.89 albertel 455: }
456: }
457:
458: # Get list of froze roles and list of recent roles
459: my @freeze_list = &Apache::loncommon::get_env_multiple('form.freezeroles');
460: my %freeze = ();
1.92 albertel 461: my %roletext = ();
462:
1.89 albertel 463: foreach my $key (@freeze_list) {
1.91 albertel 464: $freeze{$key}='1';
1.89 albertel 465: }
1.92 albertel 466:
1.89 albertel 467: my %recent_roles =
468: &Apache::lonhtmlcommon::get_recent('roles',$env{'environment.recentrolesn'});
1.91 albertel 469: my %frozen_roles =
470: &Apache::lonhtmlcommon::get_recent_frozen('roles',$env{'environment.recentrolesn'});
1.92 albertel 471: my %role_text = &rolespref_get_role_text([keys(%recent_roles)]);
1.89 albertel 472:
473: # Unset any roles that were previously frozen but aren't in list
474: foreach my $role_key (sort(keys(%recent_roles))) {
1.91 albertel 475: if (($frozen_roles{$role_key}) && (!exists($freeze{$role_key}))) {
1.154 www 476: $message .= "<br />".&Apache::lonhtmlcommon::confirm_success(&mt('Unfreezing '.$role.': [_1]',$role_text{$role_key}))."\n";
1.91 albertel 477: &Apache::lonhtmlcommon::store_recent('roles',$role_key,' ',0);
1.89 albertel 478: }
479: }
480:
481: # Freeze selected roles
482: foreach my $role_key (@freeze_list) {
1.91 albertel 483: if (!$frozen_roles{$role_key}) {
1.154 www 484: $message .= "<br />".
485: &Apache::lonhtmlcommon::confirm_success(&mt('Freezing '.$role.': [_1]',$role_text{$role_key}))."\n";
1.89 albertel 486: &Apache::lonhtmlcommon::store_recent('roles',
1.91 albertel 487: $role_key,' ',1);
1.50 albertel 488: }
489: }
1.89 albertel 490: $message .= "<hr /><br />\n";
1.152 www 491: &print_main_menu($r, $message);
1.50 albertel 492: }
493:
494:
1.28 www 495:
496: ################################################################
1.9 matthew 497: # Anonymous Discussion Name Change Subroutines #
498: ################################################################
1.5 www 499: sub screennamechanger {
500: my $r = shift;
1.59 albertel 501: my $user = $env{'user.name'};
502: my $domain = $env{'user.domain'};
1.14 www 503: my %userenv = &Apache::lonnet::get
504: ('environment',['screenname','nickname']);
1.6 www 505: my $screenname=$userenv{'screenname'};
1.14 www 506: my $nickname=$userenv{'nickname'};
1.126 droeschl 507: Apache::lonhtmlcommon::add_breadcrumb(
508: { href => '/adm/preferences?action=changescreenname',
509: text => 'Change Screen Name'});
1.147 schafran 510: $r->print(Apache::loncommon::start_page('Personal Data'));
1.126 droeschl 511: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Screen Name'));
1.133 bisitz 512: $r->print('<p>'
513: .&mt('Change the name that is displayed in your posts.')
514: .'</p>'
515: );
516: $r->print('<form name="prefs" action="/adm/preferences" method="post">'
517: .'<input type="hidden" name="action" value="verify_and_change_screenname" />'
518: .&Apache::lonhtmlcommon::start_pick_box()
519: .&Apache::lonhtmlcommon::row_title(&mt('New screenname (shown if you post anonymously)'))
520: .'<input type="text" size="20" value="'.$screenname.'" name="screenname" />'
521: .&Apache::lonhtmlcommon::row_closure()
522: .&Apache::lonhtmlcommon::row_title(&mt('New nickname (shown if you post non-anonymously)'))
523: .'<input type="text" size="20" value="'.$nickname.'" name="nickname" />'
524: .&Apache::lonhtmlcommon::row_closure()
525: .&Apache::lonhtmlcommon::row_title()
526: .'<input type="submit" value="'.&mt('Save').'" />'
527: .&Apache::lonhtmlcommon::row_closure(1)
528: .&Apache::lonhtmlcommon::end_pick_box()
529: .'</form>'
530: );
1.5 www 531: }
1.6 www 532:
533: sub verify_and_change_screenname {
534: my $r = shift;
1.59 albertel 535: my $user = $env{'user.name'};
536: my $domain = $env{'user.domain'};
1.14 www 537: # Screenname
1.59 albertel 538: my $newscreen = $env{'form.screenname'};
1.14 www 539: $newscreen=~s/[^ \w]//g;
1.6 www 540: my $message='';
541: if ($newscreen) {
1.7 www 542: &Apache::lonnet::put('environment',{'screenname' => $newscreen});
1.116 raeburn 543: &Apache::lonnet::appenv({'environment.screenname' => $newscreen});
1.152 www 544: $message=&Apache::lonhtmlcommon::confirm_success(&mt('Set new screenname to ').'<tt>"'.$newscreen.'."</tt>.');
1.6 www 545: } else {
546: &Apache::lonnet::del('environment',['screenname']);
1.139 raeburn 547: &Apache::lonnet::delenv('environment.screenname');
1.152 www 548: $message=&Apache::lonhtmlcommon::confirm_success(&mt('Reset screenname.'));
1.6 www 549: }
1.14 www 550: # Nickname
551: $message.='<br />';
1.59 albertel 552: $newscreen = $env{'form.nickname'};
1.14 www 553: $newscreen=~s/[^ \w]//g;
554: if ($newscreen) {
555: &Apache::lonnet::put('environment',{'nickname' => $newscreen});
1.116 raeburn 556: &Apache::lonnet::appenv({'environment.nickname' => $newscreen});
1.152 www 557: $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Set new nickname to ').'<tt>"'.$newscreen.'"</tt>.');
1.14 www 558: } else {
559: &Apache::lonnet::del('environment',['nickname']);
1.139 raeburn 560: &Apache::lonnet::delenv('environment.nickname');
1.152 www 561: $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Reset nickname.'));
1.14 www 562: }
1.68 www 563: &Apache::lonnet::devalidate_cache_new('namescache',$user.':'.$domain);
1.152 www 564: &print_main_menu($r, $message);
1.20 www 565: }
566:
567: ################################################################
1.98 www 568: # Icon Subroutines #
569: ################################################################
570: sub iconchanger {
571: my $r = shift;
1.154 www 572: &Apache::lonhtmlcommon::add_breadcrumb(
1.126 droeschl 573: { href => '/adm/preferences?action=changeicons',
574: text => 'Change Main Menu'});
1.147 schafran 575: $r->print(Apache::loncommon::start_page('Page Display Settings'));
1.126 droeschl 576: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Main Menu'));
577:
1.98 www 578: my $user = $env{'user.name'};
579: my $domain = $env{'user.domain'};
580: my %userenv = &Apache::lonnet::get
581: ('environment',['icons']);
582: my $iconic='checked="checked"';
583: my $classic='';
1.100 www 584: my $onlyicon='';
1.98 www 585: if ($userenv{'icons'} eq 'classic') {
586: $classic='checked="checked"';
587: $iconic='';
588: }
1.100 www 589: if ($userenv{'icons'} eq 'iconsonly') {
590: $onlyicon='checked="checked"';
591: $iconic='';
592: }
593: my $useicons=&mt('Use icons and text');
594: my $usebuttons=&mt('Use buttons and text');
595: my $useicononly=&mt('Use icons only');
1.136 schafran 596: my $change=&mt('Save');
1.98 www 597: $r->print(<<ENDSCREEN);
598: <form name="prefs" action="/adm/preferences" method="post">
599: <input type="hidden" name="action" value="verify_and_change_icons" />
600: <label><input type="radio" name="menumode" value="iconic" $iconic /> $useicons</label><br />
601: <label><input type="radio" name="menumode" value="classic" $classic /> $usebuttons</label><br />
1.100 www 602: <label><input type="radio" name="menumode" value="iconsonly" $onlyicon /> $useicononly</label><br />
1.98 www 603: <input type="submit" value="$change" />
604: </form>
605: ENDSCREEN
606: }
607:
608: sub verify_and_change_icons {
609: my $r = shift;
610: my $user = $env{'user.name'};
611: my $domain = $env{'user.domain'};
612: my $newicons = $env{'form.menumode'};
613:
614: &Apache::lonnet::put('environment',{'icons' => $newicons});
1.116 raeburn 615: &Apache::lonnet::appenv({'environment.icons' => $newicons});
1.152 www 616: &print_main_menu($r, &Apache::lonhtmlcommon::confirm_success(&mt('Set menu mode to [_1].',$newicons)));
1.98 www 617: }
618:
619: ################################################################
1.105 www 620: # Clicker Subroutines #
621: ################################################################
622:
623: sub clickerchanger {
624: my $r = shift;
1.152 www 625: &Apache::lonhtmlcommon::add_breadcrumb(
1.126 droeschl 626: { href => '/adm/preferences?action=changeclicker',
627: text => 'Register Clicker'});
1.147 schafran 628: $r->print(Apache::loncommon::start_page('Other'));
1.126 droeschl 629: $r->print(Apache::lonhtmlcommon::breadcrumbs('Register Clicker'));
1.105 www 630: my $user = $env{'user.name'};
631: my $domain = $env{'user.domain'};
632: my %userenv = &Apache::lonnet::get
633: ('environment',['clickers']);
634: my $clickers=$userenv{'clickers'};
635: $clickers=~s/\,/\n/gs;
636: my $text=&mt('Enter response device ("clicker") numbers');
1.151 bisitz 637: my $change=&mt('Save');
1.114 bisitz 638: my $helplink=&Apache::loncommon::help_open_topic('Clicker_Registration',&mt('Locating your clicker ID'));
1.105 www 639: $r->print(<<ENDSCREEN);
640: <form name="prefs" action="/adm/preferences" method="post">
641: <input type="hidden" name="action" value="verify_and_change_clicker" />
1.151 bisitz 642: <label>$helplink<br /><br />$text<br />
1.108 www 643: <textarea name="clickers" rows="5" cols="20">$clickers</textarea>
1.105 www 644: </label>
1.151 bisitz 645: <br />
1.105 www 646: <input type="submit" value="$change" />
647: </form>
648: ENDSCREEN
649: }
650:
651: sub verify_and_change_clicker {
652: my $r = shift;
653: my $user = $env{'user.name'};
654: my $domain = $env{'user.domain'};
655: my $newclickers = $env{'form.clickers'};
1.108 www 656: $newclickers=~s/[^\w\:\-]+/\,/gs;
1.105 www 657: $newclickers=~tr/a-z/A-Z/;
1.108 www 658: $newclickers=~s/[\:\-]+/\-/g;
659: $newclickers=~s/\,+/\,/g;
1.105 www 660: $newclickers=~s/^\,//;
661: $newclickers=~s/\,$//;
662: &Apache::lonnet::put('environment',{'clickers' => $newclickers});
1.116 raeburn 663: &Apache::lonnet::appenv({'environment.clickers' => $newclickers});
1.152 www 664: &print_main_menu($r, &Apache::lonhtmlcommon::confirm_success(&mt('Registering clickers: [_1]',$newclickers)));
1.105 www 665: }
666:
1.119 www 667: ################################################################
668: # Domcoord Access Subroutines #
669: ################################################################
670:
671: sub domcoordchanger {
672: my $r = shift;
1.154 www 673: &Apache::lonhtmlcommon::add_breadcrumb(
1.126 droeschl 674: { href => '/adm/preferences?action=changedomcoord',
675: text => 'Restrict Domain Coordinator Access'});
676: $r->print(Apache::loncommon::start_page('Restrict Domain Coordinator Access'));
677: $r->print(Apache::lonhtmlcommon::breadcrumbs('Restrict Domain Coordinator Access'));
1.119 www 678: my $user = $env{'user.name'};
679: my $domain = $env{'user.domain'};
680: my %userenv = &Apache::lonnet::get
1.120 www 681: ('environment',['domcoord.author']);
1.119 www 682: my $constchecked='';
683: if ($userenv{'domcoord.author'} eq 'blocked') {
684: $constchecked='checked="checked"';
685: }
1.120 www 686: my $text=&mt('By default, the Domain Coordinator can enter your construction space.');
1.119 www 687: my $construction=&mt('Block access to construction space');
1.136 schafran 688: my $change=&mt('Save');
1.119 www 689: $r->print(<<ENDSCREEN);
690: <form name="prefs" action="/adm/preferences" method="post">
691: <input type="hidden" name="action" value="verify_and_change_domcoord" />
692: $text<br />
693: <label><input type="checkbox" name="construction" $constchecked />$construction</label><br />
694: <input type="submit" value="$change" />
695: </form>
696: ENDSCREEN
697: }
698:
699: sub verify_and_change_domcoord {
700: my $r = shift;
701: my $user = $env{'user.name'};
702: my $domain = $env{'user.domain'};
1.120 www 703: my %domcoord=('domcoord.author' => '');
1.119 www 704: if ($env{'form.construction'}) { $domcoord{'domcoord.author'}='blocked'; }
705: &Apache::lonnet::put('environment',\%domcoord);
1.120 www 706: &Apache::lonnet::appenv({'environment.domcoord.author' => $domcoord{'domcoord.author'}});
1.152 www 707: &print_main_menu($r,&Apache::lonhtmlcommon::confirm_success(&mt('Registering Domain Coordinator access restrictions.')));
1.119 www 708: }
709:
1.118 www 710: #################################################################
711: ## Lock Subroutines #
712: #################################################################
713:
714: sub lockwarning {
715: my $r = shift;
716: my $title=&mt('Action locked');
717: my $texttop=&mt('LON-CAPA is currently performing the following actions:');
718: my $textbottom=&mt('Changing roles or logging out may result in data corruption.');
719: my ($num,%which)=&Apache::lonnet::get_locks();
720: my $which='';
721: foreach my $id (keys %which) {
722: $which.='<li>'.$which{$id}.'</li>';
723: }
724: my $change=&mt('Override');
725: $r->print(<<ENDSCREEN);
726: <form name="prefs" action="/adm/preferences" method="post">
727: <input type="hidden" name="action" value="verify_and_change_locks" />
728: <h1>$title</h1>
729: $texttop
730: <ul>
731: $which
732: </ul>
733: $textbottom
734: <input type="submit" value="$change" />
735: </form>
736: ENDSCREEN
737: }
738:
739: sub verify_and_change_lockwarning {
740: my $r = shift;
741: &Apache::lonnet::remove_all_locks();
742: $r->print(&mt('Cleared locks.'));
743: }
744:
745:
1.105 www 746: ################################################################
1.20 www 747: # Message Forward #
748: ################################################################
749:
750: sub msgforwardchanger {
1.102 raeburn 751: my ($r,$message) = @_;
1.59 albertel 752: my $user = $env{'user.name'};
753: my $domain = $env{'user.domain'};
1.102 raeburn 754: my %userenv = &Apache::lonnet::get('environment',['msgforward','notification','critnotification','notifywithhtml']);
1.20 www 755: my $msgforward=$userenv{'msgforward'};
1.102 raeburn 756: my %lt = &Apache::lonlocal::texthash(
757: all => 'All',
758: crit => 'Critical only',
759: reg => 'Non-critical only',
760: foad => 'Forwarding Address(es)',
1.113 raeburn 761: noti => 'Notification E-mail Address(es)',
1.110 bisitz 762: foad_exmpl => 'e.g. <tt>userA:domain1,userB:domain2,...</tt>',
1.130 schafran 763: mnot => 'E-mail Address(es) which should be notified about new LON-CAPA messages',
764: # old: 'Message Notification Email Address(es)',
1.110 bisitz 765: mnot_exmpl => 'e.g. <tt>joe@doe.com</tt>',
1.136 schafran 766: chg => 'Save',
1.104 raeburn 767: email => 'The e-mail address entered in row ',
1.102 raeburn 768: notv => 'is not a valid e-mail address',
1.103 raeburn 769: toen => "To enter multiple addresses, enter one address at a time, click 'Change' and then add the next one",
1.136 schafran 770: prme => 'Back',
1.102 raeburn 771: );
1.126 droeschl 772: Apache::lonhtmlcommon::add_breadcrumb(
773: { href => '/adm/preferences?action=changemsgforward',
774: text => 'Change Message Forwarding/Notification'});
1.147 schafran 775: $r->print(Apache::loncommon::start_page('Message Management'));
1.126 droeschl 776: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Message Forwarding/Notification'));
1.113 raeburn 777: my $forwardingHelp = &Apache::loncommon::help_open_topic("Prefs_Forwarding");
778: my $notificationHelp = &Apache::loncommon::help_open_topic("Prefs_Notification");
779: my $criticalMessageHelp = &Apache::loncommon::help_open_topic("Course_Critical_Message");
1.102 raeburn 780: my @allow_html = split(/,/,$userenv{'notifywithhtml'});
781: my %allnot = &get_notifications(\%userenv);
782: my $validatescript = &Apache::lonhtmlcommon::javascript_valid_email();
783: my $jscript = qq|
1.148 bisitz 784: <script type="text/javascript" language="JavaScript">
1.102 raeburn 785: function validate() {
786: for (var i=0; i<document.prefs.numnotify.value; i++) {
1.104 raeburn 787: var checkaddress = 0;
1.102 raeburn 788: var addr = document.prefs.elements['address_'+i].value;
1.104 raeburn 789: var rownum = i+1;
1.102 raeburn 790: if (i < document.prefs.numnotify.value-1) {
1.104 raeburn 791: if (document.prefs.elements['modify_notify_'+i].checked) {
1.102 raeburn 792: checkaddress = 1;
1.104 raeburn 793: }
1.102 raeburn 794: } else {
795: if (document.prefs.elements['add_notify_'+i].checked == true) {
796: checkaddress = 1;
797: }
798: }
1.104 raeburn 799: if (checkaddress == 1) {
1.102 raeburn 800: var addr = document.prefs.elements['address_'+i].value;
801: if (validmail(document.prefs.elements['address_'+i]) == false) {
1.104 raeburn 802: var multimsg = '';
803: if (addr.indexOf(",") >= 0) {
804: multimsg = "\\n($lt{'toen'}).";
805: }
1.110 bisitz 806: alert("$lt{'email'} "+rownum+" ('"+addr+"') $lt{'notv'}."+multimsg);
1.102 raeburn 807: return;
808: }
809: }
810: }
811: document.prefs.submit();
812: }
1.104 raeburn 813:
814: function address_changes (adnum) {
815: if (!document.prefs.elements['del_notify_'+adnum].checked) {
816: document.prefs.elements['modify_notify_'+adnum].checked = true;
817: }
818: }
819:
820: function new_address(adnum) {
821: document.prefs.elements['add_notify_'+adnum].checked = true;
822: }
823:
824: function delete_address(adnum) {
825: if (document.prefs.elements['del_notify_'+adnum].checked) {
826: document.prefs.elements['modify_notify_'+adnum].checked = false;
827: }
828: }
829:
830: function modify_address(adnum) {
831: if (document.prefs.elements['modify_notify_'+adnum].checked) {
832: document.prefs.elements['del_notify_'+adnum].checked = false;
833: }
834: }
835:
1.102 raeburn 836: $validatescript
837: </script>
838: |;
1.20 www 839: $r->print(<<ENDMSG);
1.102 raeburn 840: $jscript
841: $message
1.113 raeburn 842: <h3>$lt{'foad'} $forwardingHelp</h3>
1.88 albertel 843: <form name="prefs" action="/adm/preferences" method="post">
1.20 www 844: <input type="hidden" name="action" value="verify_and_change_msgforward" />
1.110 bisitz 845: $lt{'foad'} ($lt{'foad_exmpl'}):
1.113 raeburn 846: <input type="text" size="40" value="$msgforward" name="msgforward" /><br />
847: <h3>$lt{'noti'} $notificationHelp</h3>
1.110 bisitz 848: $lt{'mnot'} ($lt{'mnot_exmpl'}):<br />
1.102 raeburn 849: ENDMSG
850: my @sortforwards = sort (keys(%allnot));
851: my $output = &Apache::loncommon::start_data_table().
852: &Apache::loncommon::start_data_table_header_row().
1.104 raeburn 853: '<th> </th>'.
1.102 raeburn 854: '<th>'.&mt('Action').'</th>'.
855: '<th>'.&mt('Notification address').'</th><th>'.
1.113 raeburn 856: &mt('Types of message for which notification is sent').
857: $criticalMessageHelp.'</th><th>'.
1.104 raeburn 858: &mt('Excerpt retains HTML tags in message').'</th>'.
1.102 raeburn 859: &Apache::loncommon::end_data_table_header_row();
860: my $num = 0;
1.104 raeburn 861: my $counter = 1;
1.102 raeburn 862: foreach my $item (@sortforwards) {
863: $output .= &Apache::loncommon::start_data_table_row().
1.104 raeburn 864: '<td><b>'.$counter.'</b></td>'.
865: '<td><span class="LC_nobreak"><label>'.
866: '<input type="checkbox" name="modify_notify_'.
867: $num.'" onclick="javscript:modify_address('."'$num'".')" />'.
868: &mt('Modify').'</label></span> '.
869: '<span class="LC_nobreak"><label>'.
870: '<input type="checkbox" name="del_notify_'.$num.
871: '" onclick="javscript:delete_address('."'$num'".')" />'.
872: &mt('Delete').'</label></span></td>'.
1.102 raeburn 873: '<td><input type="text" value="'.$item.'" name="address_'.
1.104 raeburn 874: $num.'" onFocus="javascript:address_changes('."'$num'".
875: ')" /></td><td>';
1.102 raeburn 876: my %chk;
877: if (defined($allnot{$item}{'crit'})) {
878: if (defined($allnot{$item}{'reg'})) {
879: $chk{'all'} = 'checked="checked" ';
880: } else {
881: $chk{'crit'} = 'checked="checked" ';
882: }
883: } else {
884: $chk{'reg'} = 'checked="checked" ';
885: }
886: foreach my $type ('all','crit','reg') {
887: $output .= '<span class="LC_nobreak"><label>'.
888: '<input type="radio" name="notify_type_'.$num.
1.104 raeburn 889: '" value="'.$type.'" '.$chk{$type}.
890: ' onchange="javascript:address_changes('."'$num'".')" />'.
891: $lt{$type}.'</label></span> ';
1.102 raeburn 892: }
893: my $htmlon = '';
894: my $htmloff = '';
895: if (grep/^\Q$item\E/,@allow_html) {
896: $htmlon = 'checked="checked" ';
897: } else {
898: $htmloff = 'checked="checked" ';
899: }
900: $output .= '</td><td><label><input type="radio" name="html_'.$num.
1.104 raeburn 901: '" value="1" '.$htmlon.
902: ' onchange="javascript:address_changes('."'$num'".')" />'.
903: &mt('Yes').'</label> '.
1.102 raeburn 904: '<label><input type="radio" name="html_'.$num.'" value="0" '.
1.104 raeburn 905: $htmloff. ' onchange="javascript:address_changes('."'$num'".
906: ')" />'.
907: &mt('No').'</label></td>'.
1.102 raeburn 908: &Apache::loncommon::end_data_table_row();
909: $num ++;
1.104 raeburn 910: $counter ++;
1.102 raeburn 911: }
912: my %defchk = (
913: all => 'checked="checked" ',
914: crit => '',
915: reg => '',
916: );
917: $output .= &Apache::loncommon::start_data_table_row().
1.104 raeburn 918: '<td><b>'.$counter.'</b></td>'.
919: '<td><span class="LC_nobreak"><label>'.
920: '<input type="checkbox" name="add_notify_'.$num.
921: '" value="1" />'.&mt('Add new address').'</label></span></td>'.
1.102 raeburn 922: '<td><input type="text" value="" name="address_'.$num.
1.104 raeburn 923: '" onFocus="javascript:new_address('."'$num'".')" /></td><td>';
1.102 raeburn 924: foreach my $type ('all','crit','reg') {
925: $output .= '<span class="LC_nobreak"><label>'.
926: '<input type="radio" name="notify_type_'.$num.
927: '" value="'.$type.'" '.$defchk{$type}.'/>'.
928: $lt{$type}.'</label></span> ';
929: }
930: $output .= '</td><td><label><input type="radio" name="html_'.$num.
931: '" value="1" />'.&mt('Yes').'</label> '.
932: '<label><input type="radio" name="html_'.$num.'" value="0" '.
933: ' checked="checked" />'.
934: &mt('No').'</label></td>'.
935: &Apache::loncommon::end_data_table_row().
936: &Apache::loncommon::end_data_table();
937: $num ++;
938: $r->print($output);
939: $r->print(qq|
1.113 raeburn 940: <br /><hr />
1.102 raeburn 941: <input type="hidden" name="numnotify" value="$num" />
1.136 schafran 942: <input type="button" value="$lt{'prme'}" onclick="location.href='/adm/preferences'" />
1.102 raeburn 943: <input type="button" value="$lt{'chg'}" onclick="javascript:validate()" />
1.20 www 944: </form>
1.102 raeburn 945: |);
946:
947: }
948:
949: sub get_notifications {
950: my ($userenv) = @_;
951: my %allnot;
952: my @critnot = split(/,/,$userenv->{'critnotification'});
953: my @regnot = split(/,/,$userenv->{'notification'});
954: foreach my $item (@critnot) {
955: $allnot{$item}{crit} = 1;
956: }
957: foreach my $item (@regnot) {
958: $allnot{$item}{reg} = 1;
959: }
960: return %allnot;
1.20 www 961: }
962:
963: sub verify_and_change_msgforward {
964: my $r = shift;
1.59 albertel 965: my $user = $env{'user.name'};
966: my $domain = $env{'user.domain'};
1.20 www 967: my $newscreen = '';
968: my $message='';
1.59 albertel 969: foreach (split(/\,/,$env{'form.msgforward'})) {
1.20 www 970: my ($msuser,$msdomain)=split(/[\@\:]/,$_);
1.95 albertel 971: $msuser = &LONCAPA::clean_username($msuser);
972: $msdomain = &LONCAPA::clean_domain($msdomain);
1.20 www 973: if (($msuser) && ($msdomain)) {
974: if (&Apache::lonnet::homeserver($msuser,$msdomain) ne 'no_host') {
975: $newscreen.=$msuser.':'.$msdomain.',';
976: } else {
1.110 bisitz 977: $message.= &mt('No such user: ').'<tt>'.$msuser.':'.$msdomain.'</tt><br>';
1.20 www 978: }
979: }
980: }
981: $newscreen=~s/\,$//;
982: if ($newscreen) {
983: &Apache::lonnet::put('environment',{'msgforward' => $newscreen});
1.116 raeburn 984: &Apache::lonnet::appenv({'environment.msgforward' => $newscreen});
1.110 bisitz 985: $message .= &mt('Set message forwarding to ').'<tt>"'.$newscreen.'"</tt>.'
986: .'<br />';
1.20 www 987: } else {
988: &Apache::lonnet::del('environment',['msgforward']);
1.139 raeburn 989: &Apache::lonnet::delenv('environment.msgforward');
1.102 raeburn 990: $message.= &mt("Set message forwarding to 'off'.").'<br />';
1.20 www 991: }
1.102 raeburn 992: my $critnotification;
993: my $notification;
994: my $notify_with_html;
995: my $lastnotify = $env{'form.numnotify'}-1;
1.104 raeburn 996: my $totaladdresses = 0;
1.102 raeburn 997: for (my $i=0; $i<$env{'form.numnotify'}; $i++) {
998: if ((!defined($env{'form.del_notify_'.$i})) &&
1.104 raeburn 999: ((($i==$lastnotify) && ($env{'form.add_notify_'.$lastnotify} == 1)) ||
1.102 raeburn 1000: ($i<$lastnotify))) {
1001: if (defined($env{'form.address_'.$i})) {
1002: if ($env{'form.notify_type_'.$i} eq 'all') {
1003: $critnotification .= $env{'form.address_'.$i}.',';
1004: $notification .= $env{'form.address_'.$i}.',';
1005: } elsif ($env{'form.notify_type_'.$i} eq 'crit') {
1006: $critnotification .= $env{'form.address_'.$i}.',';
1007: } elsif ($env{'form.notify_type_'.$i} eq 'reg') {
1008: $notification .= $env{'form.address_'.$i}.',';
1009: }
1010: if ($env{'form.html_'.$i} eq '1') {
1011: $notify_with_html .= $env{'form.address_'.$i}.',';
1012: }
1.104 raeburn 1013: $totaladdresses ++;
1.102 raeburn 1014: }
1015: }
1016: }
1017: $critnotification =~ s/,$//;
1018: $critnotification=~s/\s//gs;
1019: $notification =~ s/,$//;
1.20 www 1020: $notification=~s/\s//gs;
1.102 raeburn 1021: $notify_with_html =~ s/,$//;
1022: $notify_with_html =~ s/\s//gs;
1.20 www 1023: if ($notification) {
1024: &Apache::lonnet::put('environment',{'notification' => $notification});
1.116 raeburn 1025: &Apache::lonnet::appenv({'environment.notification' => $notification});
1.110 bisitz 1026: $message.=&mt('Set non-critical message notification address(es) to ').'<tt>"'.$notification.'"</tt>.<br />';
1.20 www 1027: } else {
1028: &Apache::lonnet::del('environment',['notification']);
1.139 raeburn 1029: &Apache::lonnet::delenv('environment.notification');
1.110 bisitz 1030: $message.=&mt("Set non-critical message notification to 'off'.").'<br />';
1.20 www 1031: }
1032: if ($critnotification) {
1033: &Apache::lonnet::put('environment',{'critnotification' => $critnotification});
1.116 raeburn 1034: &Apache::lonnet::appenv({'environment.critnotification' => $critnotification});
1.110 bisitz 1035: $message.=&mt('Set critical message notification address(es) to ').'<tt>"'.$critnotification.'"</tt>.<br />';
1.20 www 1036: } else {
1037: &Apache::lonnet::del('environment',['critnotification']);
1.139 raeburn 1038: &Apache::lonnet::delenv('environment.critnotification');
1.110 bisitz 1039: $message.=&mt("Set critical message notification to 'off'.").'<br />';
1.102 raeburn 1040: }
1041: if ($critnotification || $notification) {
1042: if ($notify_with_html) {
1043: &Apache::lonnet::put('environment',{'notifywithhtml' => $notify_with_html});
1.116 raeburn 1044: &Apache::lonnet::appenv({'environment.notifywithhtml' => $notify_with_html});
1.110 bisitz 1045: $message.=&mt('Set address(es) to receive excerpts with html retained ').'<tt>"'.$notify_with_html.'"</tt>.';
1.102 raeburn 1046: } else {
1047: &Apache::lonnet::del('environment',['notifywithhtml']);
1.139 raeburn 1048: &Apache::lonnet::delenv('environment.notifywithhtml');
1.104 raeburn 1049: if ($totaladdresses == 1) {
1050: $message.=&mt("Set notification address to receive excerpts with html stripped.");
1051: } else {
1052: $message.=&mt("Set all notification addresses to receive excerpts with html stripped.");
1053: }
1.102 raeburn 1054: }
1055: } else {
1056: &Apache::lonnet::del('environment',['notifywithhtml']);
1.139 raeburn 1057: &Apache::lonnet::delenv('environment.notifywithhtml');
1.102 raeburn 1058: }
1059: if ($message) {
1060: $message .= '<br /><hr />';
1.20 www 1061: }
1.109 albertel 1062: &Apache::loncommon::flush_email_cache($user,$domain);
1.102 raeburn 1063: &msgforwardchanger($r,$message);
1.6 www 1064: }
1065:
1.12 www 1066: ################################################################
1.19 www 1067: # Colors #
1.12 www 1068: ################################################################
1069:
1.19 www 1070: sub colorschanger {
1.12 www 1071: my $r = shift;
1.126 droeschl 1072: Apache::lonhtmlcommon::add_breadcrumb(
1073: { href => '/adm/preferences?action=changecolors',
1074: text => 'Change Colors'});
1.147 schafran 1075: $r->print(Apache::loncommon::start_page('Page Display Settings'));
1.126 droeschl 1076: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Colors'));
1.19 www 1077: # figure out colors
1.80 albertel 1078: my $function=&Apache::loncommon::get_users_function();
1.19 www 1079: my $domain=&Apache::loncommon::determinedomain();
1.157 ! bisitz 1080: my %colortypes=&Apache::lonlocal::texthash(
! 1081: 'pgbg' => 'Page Background Color',
! 1082: 'tabbg' => 'Header Background Color',
! 1083: 'sidebg' => 'Header Border Color',
! 1084: 'font' => 'Font Color',
! 1085: 'fontmenu' => 'Font Menu Color',
! 1086: 'link' => 'Un-Visited Link Color',
! 1087: 'vlink' => 'Visited Link Color',
! 1088: 'alink' => 'Active Link Color',
! 1089: );
1.82 albertel 1090: my $start_data_table = &Apache::loncommon::start_data_table();
1.19 www 1091: my $chtable='';
1.22 matthew 1092: foreach my $item (sort(keys(%colortypes))) {
1.19 www 1093: my $curcol=&Apache::loncommon::designparm($function.'.'.$item,$domain);
1.82 albertel 1094: $chtable.=&Apache::loncommon::start_data_table_row().
1.83 albertel 1095: '<td>'.$colortypes{$item}.'</td><td style="background: '.$curcol.
1.19 www 1096: '"> </td><td><input name="'.$item.
1.21 www 1097: '" size="10" value="'.$curcol.
1098: '" /></td><td><a href="javascript:pjump('."'color_custom','".$colortypes{$item}.
1.19 www 1099: "','".$curcol."','"
1.157 ! bisitz 1100: .$item."','parmform.pres','psub'".');">'.&mt('Select').'</a></td>'.
1.83 albertel 1101: &Apache::loncommon::end_data_table_row()."\n";
1.19 www 1102: }
1.82 albertel 1103: my $end_data_table = &Apache::loncommon::end_data_table();
1.23 matthew 1104: my $pjump_def = &Apache::lonhtmlcommon::pjump_javascript_definition();
1.157 ! bisitz 1105: my $savebutton = &mt('Save');
! 1106: my $resetbutton = &mt('Reset All');
! 1107: my $resetbuttondesc = &mt('Reset All Colors to Default');
1.19 www 1108: $r->print(<<ENDCOL);
1.148 bisitz 1109: <script type="text/javascript" language="JavaScript">
1.19 www 1110:
1111: function pclose() {
1112: parmwin=window.open("/adm/rat/empty.html","LONCAPAparms",
1113: "height=350,width=350,scrollbars=no,menubar=no");
1114: parmwin.close();
1115: }
1116:
1.23 matthew 1117: $pjump_def
1.19 www 1118:
1119: function psub() {
1120: pclose();
1121: if (document.parmform.pres_marker.value!='') {
1.21 www 1122: if (document.parmform.pres_type.value!='') {
1.77 albertel 1123: eval('document.prefs.'+
1.21 www 1124: document.parmform.pres_marker.value+
1.19 www 1125: '.value=document.parmform.pres_value.value;');
1.21 www 1126: }
1.19 www 1127: } else {
1128: document.parmform.pres_value.value='';
1129: document.parmform.pres_marker.value='';
1130: }
1131: }
1132:
1133:
1134: </script>
1.21 www 1135: <form name="parmform">
1136: <input type="hidden" name="pres_marker" />
1137: <input type="hidden" name="pres_type" />
1138: <input type="hidden" name="pres_value" />
1139: </form>
1.88 albertel 1140: <form name="prefs" action="/adm/preferences" method="post">
1.19 www 1141: <input type="hidden" name="action" value="verify_and_change_colors" />
1.82 albertel 1142: $start_data_table
1.19 www 1143: $chtable
1.82 albertel 1144: $end_data_table
1.19 www 1145: </table>
1.157 ! bisitz 1146: <p>
! 1147: <input type="submit" value="$savebutton" />
! 1148: <input type="submit" name="resetall" value="$resetbutton" title="$resetbuttondesc" />
! 1149: </p>
1.12 www 1150: </form>
1.19 www 1151: ENDCOL
1.12 www 1152: }
1153:
1.19 www 1154: sub verify_and_change_colors {
1.12 www 1155: my $r = shift;
1.19 www 1156: # figure out colors
1.80 albertel 1157: my $function=&Apache::loncommon::get_users_function();
1.19 www 1158: my $domain=&Apache::loncommon::determinedomain();
1.157 ! bisitz 1159: my %colortypes=&Apache::lonlocal::texthash(
! 1160: 'pgbg' => 'Page Background Color',
! 1161: 'tabbg' => 'Header Background Color',
! 1162: 'sidebg' => 'Header Border Color',
! 1163: 'font' => 'Font Color',
! 1164: 'fontmenu' => 'Font Menu Color',
! 1165: 'link' => 'Un-Visited Link Color',
! 1166: 'vlink' => 'Visited Link Color',
! 1167: 'alink' => 'Active Link Color',
! 1168: );
1.19 www 1169:
1.12 www 1170: my $message='';
1.21 www 1171: foreach my $item (keys %colortypes) {
1.59 albertel 1172: my $color=$env{'form.'.$item};
1.21 www 1173: my $entry='color.'.$function.'.'.$item;
1.59 albertel 1174: if (($color=~/^\#[0-9A-Fa-f]{6}$/) && (!$env{'form.resetall'})) {
1.21 www 1175: &Apache::lonnet::put('environment',{$entry => $color});
1.116 raeburn 1176: &Apache::lonnet::appenv({'environment.'.$entry => $color});
1.157 ! bisitz 1177: $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Set [_1] to [_2]','<i>'.$colortypes{$item}.'</i>','<tt>"'.$color.'"</tt>'))
! 1178: .'<br />';
1.21 www 1179: } else {
1180: &Apache::lonnet::del('environment',[$entry]);
1.138 schafran 1181: &Apache::lonnet::delenv('environment.'.$entry);
1.157 ! bisitz 1182: $message.=&Apache::lonhtmlcommon::confirm_success(&mt('Reset [_1]','<i>'.$colortypes{$item}.'</i>'))
! 1183: .'<br />';
1.21 www 1184: }
1185: }
1.157 ! bisitz 1186:
1.84 albertel 1187: my $now = time;
1188: &Apache::lonnet::put('environment',{'color.timestamp' => $now});
1.116 raeburn 1189: &Apache::lonnet::appenv({'environment.color.timestamp' => $now});
1.84 albertel 1190:
1.152 www 1191: &print_main_menu($r, $message);
1.12 www 1192: }
1193:
1.4 matthew 1194: ######################################################
1195: # password handler subroutines #
1196: ######################################################
1.3 matthew 1197: sub passwordchanger {
1.94 raeburn 1198: my ($r,$errormessage,$caller,$mailtoken) = @_;
1.4 matthew 1199: # This function is a bit of a mess....
1.3 matthew 1200: # Passwords are encrypted using londes.js (DES encryption)
1.4 matthew 1201: $errormessage = ($errormessage || '');
1.94 raeburn 1202: my ($user,$domain,$currentpass,$defdom);
1.152 www 1203: &Apache::lonhtmlcommon::add_breadcrumb(
1.126 droeschl 1204: { href => '/adm/preferences?action=changepass',
1205: text => 'Change Password'});
1.144 raeburn 1206: unless ($caller eq 'reset_by_email') {
1.147 schafran 1207: $r->print(Apache::loncommon::start_page('Personal Data'));
1.144 raeburn 1208: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Password'));
1209: }
1.94 raeburn 1210: if ((!defined($caller)) || ($caller eq 'preferences')) {
1211: $user = $env{'user.name'};
1212: $domain = $env{'user.domain'};
1213: if (!defined($caller)) {
1214: $caller = 'preferences';
1215: }
1216: } elsif ($caller eq 'reset_by_email') {
1217: $defdom = $r->dir_config('lonDefDomain');
1218: my %data = &Apache::lonnet::tmpget($mailtoken);
1219: if (keys(%data) == 0) {
1.155 bisitz 1220: $r->print(&mt('Sorry, the URL you provided to complete the reset of your password was invalid. Either the token included in the URL has been deleted or the URL you provided was invalid. Please submit a [_1]new request[_2] for a password reset, and follow the link to the new URL included in the e-mail that will be sent to you, to allow you to enter a new password.'
1221: ,'<a href="/adm/resetpw">','</a>')
1222: );
1.94 raeburn 1223: return;
1224: }
1225: if (defined($data{time})) {
1226: if (time - $data{'time'} < 7200) {
1227: $user = $data{'username'};
1228: $domain = $data{'domain'};
1229: $currentpass = $data{'temppasswd'};
1230: } else {
1231: $r->print(&mt('Sorry, the token generated when you requested a password reset has expired.').'<br />');
1232: return;
1233: }
1234: } else {
1235: $r->print(&mt('Sorry, the URL generated when you requested reset of your password contained incomplete information.').'<br />');
1236: return;
1237: }
1238: } else {
1239: $r->print(&mt('Page requested in unexpected context').'<br />');
1240: return;
1241: }
1.3 matthew 1242: my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
1243: # Check for authentication types that allow changing of the password.
1244: return if ($currentauth !~ /^(unix|internal):/);
1245: #
1246: # Generate keys
1247: my ($lkey_cpass ,$ukey_cpass ) = &des_keys();
1248: my ($lkey_npass1,$ukey_npass1) = &des_keys();
1249: my ($lkey_npass2,$ukey_npass2) = &des_keys();
1.4 matthew 1250: # Store the keys in the log files
1.3 matthew 1251: my $lonhost = $r->dir_config('lonHostID');
1252: my $logtoken=Apache::lonnet::reply('tmpput:'
1253: .$ukey_cpass . $lkey_cpass .'&'
1254: .$ukey_npass1 . $lkey_npass1.'&'
1255: .$ukey_npass2 . $lkey_npass2,
1256: $lonhost);
1.4 matthew 1257: # Hexify the keys for output as javascript variables
1.94 raeburn 1258: my %hexkey;
1259: $hexkey{'ukey_cpass'} = hex($ukey_cpass);
1260: $hexkey{'lkey_cpass'} = hex($lkey_cpass);
1261: $hexkey{'ukey_npass1'} = hex($ukey_npass1);
1262: $hexkey{'lkey_npass1'} = hex($lkey_npass1);
1263: $hexkey{'ukey_npass2'} = hex($ukey_npass2);
1264: $hexkey{'lkey_npass2'} = hex($lkey_npass2);
1.3 matthew 1265: # Output javascript to deal with passwords
1.4 matthew 1266: # Output DES javascript
1.3 matthew 1267: {
1268: my $include = $r->dir_config('lonIncludes');
1269: my $jsh=Apache::File->new($include."/londes.js");
1270: $r->print(<$jsh>);
1271: }
1.94 raeburn 1272: $r->print(&jscript_send($caller));
1.3 matthew 1273: $r->print(<<ENDFORM);
1.94 raeburn 1274: $errormessage
1275:
1276: <p>
1277: <!-- We separate the forms into 'server' and 'client' in order to
1278: ensure that unencrypted passwords will not be sent out by a
1279: crappy browser -->
1280: ENDFORM
1281: $r->print(&server_form($logtoken,$caller,$mailtoken));
1282: $r->print(&client_form($caller,\%hexkey,$currentpass,$defdom));
1283:
1284: #
1285: return;
1286: }
1287:
1288: sub jscript_send {
1289: my ($caller) = @_;
1290: my $output = qq|
1.148 bisitz 1291: <script type="text/javascript" language="JavaScript">
1.3 matthew 1292:
1293: function send() {
1294: uextkey=this.document.client.elements.ukey_cpass.value;
1295: lextkey=this.document.client.elements.lkey_cpass.value;
1296: initkeys();
1297:
1.52 raeburn 1298: this.document.pserver.elements.currentpass.value
1.3 matthew 1299: =crypted(this.document.client.elements.currentpass.value);
1300:
1301: uextkey=this.document.client.elements.ukey_npass1.value;
1302: lextkey=this.document.client.elements.lkey_npass1.value;
1303: initkeys();
1.52 raeburn 1304: this.document.pserver.elements.newpass_1.value
1.3 matthew 1305: =crypted(this.document.client.elements.newpass_1.value);
1306:
1307: uextkey=this.document.client.elements.ukey_npass2.value;
1308: lextkey=this.document.client.elements.lkey_npass2.value;
1309: initkeys();
1.52 raeburn 1310: this.document.pserver.elements.newpass_2.value
1.3 matthew 1311: =crypted(this.document.client.elements.newpass_2.value);
1.94 raeburn 1312: |;
1313: if ($caller eq 'reset_by_email') {
1314: $output .= qq|
1315: this.document.pserver.elements.uname.value =
1316: this.document.client.elements.uname.value;
1317: this.document.pserver.elements.udom.value =
1318: this.document.client.elements.udom.options[this.document.client.elements.udom.selectedIndex].value;
1319: |;
1320: }
1321: $ output .= qq|
1.52 raeburn 1322: this.document.pserver.submit();
1.3 matthew 1323: }
1324: </script>
1.94 raeburn 1325: |;
1326: }
1.3 matthew 1327:
1.94 raeburn 1328: sub client_form {
1329: my ($caller,$hexkey,$currentpass,$defdom) = @_;
1.99 www 1330: my %lt=&Apache::lonlocal::texthash(
1.115 raeburn 1331: 'email' => 'E-mail Address',
1.99 www 1332: 'username' => 'Username',
1333: 'domain' => 'Domain',
1334: 'currentpass' => 'Current Password',
1335: 'newpass' => 'New Password',
1336: 'confirmpass' => 'Confirm Password',
1.136 schafran 1337: 'changepass' => 'Save');
1.99 www 1338:
1.94 raeburn 1339: my $output = qq|
1.3 matthew 1340: <form name="client" >
1341: <table>
1.94 raeburn 1342: |;
1343: if ($caller eq 'reset_by_email') {
1344: $output .= qq|
1.99 www 1345: <tr><td class="LC_preferences_labeltext"><label for="email">$lt{'email'}</label>:</td>
1.97 raeburn 1346: <td><input type="text" name="email" size="30" /> </td></tr>
1.99 www 1347: <tr><td class="LC_preferences_labeltext"><label for="uname">$lt{'username'}</label>:</td>
1.94 raeburn 1348: <td>
1.97 raeburn 1349: <input type="text" name="uname" size="15" />
1.94 raeburn 1350: <input type="hidden" name="currentpass" value="$currentpass" />
1351: </td></tr>
1.115 raeburn 1352: <tr><td class="LC_preferences_labeltext"><label for="udom">$lt{'domain'}</label>:</td>
1.94 raeburn 1353: <td>
1354: |;
1355: $output .= &Apache::loncommon::select_dom_form($defdom,'udom').'
1356: </td>
1357: </tr>
1358: ';
1359: } else {
1360: $output .= qq|
1.99 www 1361: <tr><td class="LC_preferences_labeltext"><label for="currentpass">$lt{'currentpass'}</label></td>
1.4 matthew 1362: <td><input type="password" name="currentpass" size="10"/> </td></tr>
1.94 raeburn 1363: |;
1364: }
1365: $output .= <<"ENDFORM";
1.99 www 1366: <tr><td class="LC_preferences_labeltext"><label for="newpass_1">$lt{'newpass'}</label></td>
1.4 matthew 1367: <td><input type="password" name="newpass_1" size="10" /> </td></tr>
1.99 www 1368: <tr><td class="LC_preferences_labeltext"><label for="newpass_2">$lt{'confirmpass'}</label></td>
1.4 matthew 1369: <td><input type="password" name="newpass_2" size="10" /> </td></tr>
1.3 matthew 1370: <tr><td colspan="2" align="center">
1.149 bisitz 1371: <input type="button" value="$lt{'changepass'}" onClick="send();" />
1.3 matthew 1372: </table>
1.94 raeburn 1373: <input type="hidden" name="ukey_cpass" value="$hexkey->{'ukey_cpass'}" />
1374: <input type="hidden" name="lkey_cpass" value="$hexkey->{'lkey_cpass'}" />
1375: <input type="hidden" name="ukey_npass1" value="$hexkey->{'ukey_npass1'}" />
1376: <input type="hidden" name="lkey_npass1" value="$hexkey->{'lkey_npass1'}" />
1377: <input type="hidden" name="ukey_npass2" value="$hexkey->{'ukey_npass2'}" />
1378: <input type="hidden" name="lkey_npass2" value="$hexkey->{'lkey_npass2'}" />
1.3 matthew 1379: </form>
1380: </p>
1381: ENDFORM
1.94 raeburn 1382: return $output;
1383: }
1384:
1385: sub server_form {
1386: my ($logtoken,$caller,$mailtoken) = @_;
1387: my $action = '/adm/preferences';
1388: if ($caller eq 'reset_by_email') {
1389: $action = '/adm/resetpw';
1390: }
1391: my $output = qq|
1392: <form name="pserver" action="$action" method="post">
1393: <input type="hidden" name="logtoken" value="$logtoken" />
1394: <input type="hidden" name="currentpass" value="" />
1395: <input type="hidden" name="newpass_1" value="" />
1396: <input type="hidden" name="newpass_2" value="" />
1397: |;
1398: if ($caller eq 'reset_by_email') {
1399: $output .= qq|
1400: <input type="hidden" name="token" value="$mailtoken" />
1401: <input type="hidden" name="uname" value="" />
1402: <input type="hidden" name="udom" value="" />
1403:
1404: |;
1405: }
1406: $output .= qq|
1407: <input type="hidden" name="action" value="verify_and_change_pass" />
1408: </form>
1409: |;
1410: return $output;
1.3 matthew 1411: }
1412:
1413: sub verify_and_change_password {
1.94 raeburn 1414: my ($r,$caller,$mailtoken) = @_;
1415: my ($user,$domain,$homeserver);
1416: if ($caller eq 'reset_by_email') {
1417: $user = $env{'form.uname'};
1418: $domain = $env{'form.udom'};
1419: if ($user ne '' && $domain ne '') {
1420: $homeserver = &Apache::lonnet::homeserver($user,$domain);
1421: if ($homeserver eq 'no_host') {
1.99 www 1422: &passwordchanger($r,"<p>\n<span class='LC_error'>".
1423: &mt("Invalid username and/or domain")."</span>\n</p>",
1.94 raeburn 1424: $caller,$mailtoken);
1425: return 1;
1426: }
1427: } else {
1.99 www 1428: &passwordchanger($r,"<p>\n<span class='LC_error'>".
1429: &mt("Username and domain were blank")."</span>\n</p>",
1.94 raeburn 1430: $caller,$mailtoken);
1431: return 1;
1432: }
1433: } else {
1434: $user = $env{'user.name'};
1435: $domain = $env{'user.domain'};
1436: $homeserver = $env{'user.home'};
1437: }
1.3 matthew 1438: my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
1.4 matthew 1439: # Check for authentication types that allow changing of the password.
1.94 raeburn 1440: if ($currentauth !~ /^(unix|internal):/) {
1441: if ($caller eq 'reset_by_email') {
1.99 www 1442: &passwordchanger($r,"<p>\n<span class='LC_error'>".
1443: &mt("Authentication type for this user can not be changed by this mechanism").
1444: "</span>\n</p>",
1.94 raeburn 1445: $caller,$mailtoken);
1446: return 1;
1447: } else {
1448: return;
1449: }
1450: }
1.3 matthew 1451: #
1.59 albertel 1452: my $currentpass = $env{'form.currentpass'};
1453: my $newpass1 = $env{'form.newpass_1'};
1454: my $newpass2 = $env{'form.newpass_2'};
1455: my $logtoken = $env{'form.logtoken'};
1.3 matthew 1456: # Check for empty data
1.4 matthew 1457: unless (defined($currentpass) &&
1458: defined($newpass1) &&
1459: defined($newpass2) ){
1.99 www 1460: &passwordchanger($r,"<p>\n<span class='LC_error'>".
1461: &mt("One or more password fields were blank").
1462: "</span>\n</p>",$caller,$mailtoken);
1.3 matthew 1463: return;
1464: }
1.16 albertel 1465: # Get the keys
1466: my $lonhost = $r->dir_config('lonHostID');
1.3 matthew 1467: my $tmpinfo = Apache::lonnet::reply('tmpget:'.$logtoken,$lonhost);
1468: if (($tmpinfo=~/^error/) || ($tmpinfo eq 'con_lost')) {
1.4 matthew 1469: # I do not a have a better idea about how to handle this
1.94 raeburn 1470: my $tryagain_text = &mt('Please log out and try again.');
1471: if ($caller eq 'reset_by_email') {
1472: $tryagain_text = &mt('Please try again later.');
1473: }
1.101 albertel 1474: my $unable=&mt("Unable to retrieve saved token for password decryption");
1.3 matthew 1475: $r->print(<<ENDERROR);
1476: <p>
1.99 www 1477: <span class="LC_error">$unable. $tryagain_text</span>
1.3 matthew 1478: </p>
1479: ENDERROR
1.4 matthew 1480: # Probably should log an error here
1.75 albertel 1481: return 1;
1.3 matthew 1482: }
1483: my ($ckey,$n1key,$n2key)=split(/&/,$tmpinfo);
1.4 matthew 1484: #
1.17 matthew 1485: $currentpass = &des_decrypt($ckey ,$currentpass);
1486: $newpass1 = &des_decrypt($n1key,$newpass1);
1487: $newpass2 = &des_decrypt($n2key,$newpass2);
1.94 raeburn 1488: #
1489: if ($caller eq 'reset_by_email') {
1490: my %data = &Apache::lonnet::tmpget($mailtoken);
1.117 raeburn 1491: if (keys(%data) == 0) {
1492: &passwordchanger($r,
1493: '<span class="LC_error">'.
1494: &mt('Could not verify current authentication.').' '.
1495: &mt('Please try again.').'</span>',$caller,$mailtoken);
1496: return 1;
1497: }
1.94 raeburn 1498: if ($currentpass ne $data{'temppasswd'}) {
1499: &passwordchanger($r,
1.99 www 1500: '<span class="LC_error">'.
1.110 bisitz 1501: &mt('Could not verify current authentication.').' '.
1502: &mt('Please try again.').'</span>',$caller,$mailtoken);
1.94 raeburn 1503: return 1;
1504: }
1505: }
1.3 matthew 1506: if ($newpass1 ne $newpass2) {
1.4 matthew 1507: &passwordchanger($r,
1.99 www 1508: '<span class="LC_error">'.
1.110 bisitz 1509: &mt('The new passwords you entered do not match.').' '.
1510: &mt('Please try again.').'</span>',$caller,$mailtoken);
1.75 albertel 1511: return 1;
1.4 matthew 1512: }
1513: if (length($newpass1) < 7) {
1514: &passwordchanger($r,
1.99 www 1515: '<span class="LC_error">'.
1.110 bisitz 1516: &mt('Passwords must be a minimum of 7 characters long.').' '.
1517: &mt('Please try again.').'</span>',$caller,$mailtoken);
1.75 albertel 1518: return 1;
1.3 matthew 1519: }
1.4 matthew 1520: #
1521: # Check for bad characters
1522: my $badpassword = 0;
1523: foreach (split(//,$newpass1)) {
1524: $badpassword = 1 if ((ord($_)<32)||(ord($_)>126));
1525: }
1526: if ($badpassword) {
1527: # I can't figure out how to enter bad characters on my browser.
1.99 www 1528: my $errormessage ='<span class="LC_error">'.
1.110 bisitz 1529: &mt('The password you entered contained illegal characters.').'<br />'.
1.99 www 1530: &mt('Valid characters are').(<<"ENDERROR");
1531: : space and <br />
1.4 matthew 1532: <pre>
1533: !"\#$%&\'()*+,-./0123456789:;<=>?\@
1534: ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}~
1.99 www 1535: </pre></span>
1.4 matthew 1536: ENDERROR
1.94 raeburn 1537: &passwordchanger($r,$errormessage,$caller,$mailtoken);
1538: return 1;
1.4 matthew 1539: }
1540: #
1541: # Change the password (finally)
1542: my $result = &Apache::lonnet::changepass
1.94 raeburn 1543: ($user,$domain,$currentpass,$newpass1,$homeserver,$caller);
1.4 matthew 1544: # Inform the user the password has (not?) been changed
1.126 droeschl 1545: my $message;
1.4 matthew 1546: if ($result =~ /^ok$/) {
1.152 www 1547: $message = &Apache::lonhtmlcommon::confirm_success(&mt('The password for [_1] was successfully changed.',$user));
1.144 raeburn 1548: if ($caller eq 'reset_by_email') {
1549: $r->print($message.'<br />');
1550: } else {
1551: &print_main_menu($r, $message);
1552: }
1.4 matthew 1553: } else {
1554: # error error: run in circles, scream and shout
1.154 www 1555: $message = &Apache::lonhtmlcommon::confirm_success(
1556: &mt("The password for [_1] was not changed.",$user).' '.&mt('Please make sure your old password was entered correctly.'),1);
1.144 raeburn 1557: unless ($caller eq 'reset_by_email') {
1558: &print_main_menu($r, $message);
1559: }
1.75 albertel 1560: return 1;
1.4 matthew 1561: }
1562: return;
1.3 matthew 1563: }
1564:
1.42 raeburn 1565: ################################################################
1566: # discussion display subroutines
1567: ################################################################
1568: sub discussionchanger {
1569: my $r = shift;
1.126 droeschl 1570: Apache::lonhtmlcommon::add_breadcrumb(
1571: { href => '/adm/preferences?action=changediscussions',
1572: text => 'Change Discussion Preferences'});
1.147 schafran 1573: $r->print(Apache::loncommon::start_page('Message Management'));
1.126 droeschl 1574: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Discussion Preferences'));
1.59 albertel 1575: my $user = $env{'user.name'};
1576: my $domain = $env{'user.domain'};
1.42 raeburn 1577: my %userenv = &Apache::lonnet::get
1.43 raeburn 1578: ('environment',['discdisplay','discmarkread']);
1579: my $discdisp = 'allposts';
1580: my $discmark = 'onmark';
1581:
1582: if (defined($userenv{'discdisplay'})) {
1583: unless ($userenv{'discdisplay'} eq '') {
1584: $discdisp = $userenv{'discdisplay'};
1585: }
1586: }
1587: if (defined($userenv{'discmarkread'})) {
1588: unless ($userenv{'discdisplay'} eq '') {
1589: $discmark = $userenv{'discmarkread'};
1590: }
1591: }
1592:
1593: my $newdisp = 'unread';
1594: my $newmark = 'ondisp';
1595:
1596: my $function = &Apache::loncommon::get_users_function();
1597: my $color = &Apache::loncommon::designparm($function.'.tabbg',
1.59 albertel 1598: $env{'user.domain'});
1.43 raeburn 1599: my %lt = &Apache::lonlocal::texthash(
1600: 'pref' => 'Display Preference',
1601: 'curr' => 'Current setting ',
1602: 'actn' => 'Action',
1.135 schafran 1603: 'sdpf' => 'Set display preferences for discussion posts for both discussion boards and individual resources in all your courses.',
1.43 raeburn 1604: 'prca' => 'Preferences can be set that determine',
1.135 schafran 1605: 'whpo' => 'Which posts are displayed when you display a discussion board or resource, and',
1.43 raeburn 1606: 'unwh' => 'Under what circumstances posts are identfied as "New"',
1607: 'allposts' => 'All posts',
1608: 'unread' => 'New posts only',
1609: 'ondisp' => 'Once displayed',
1610: 'onmark' => 'Once marked as read',
1611: 'disa' => 'Posts displayed?',
1612: 'npmr' => 'New posts cease to be identified as "New"?',
1613: 'thde' => 'The preferences you set here can be overridden within each individual discussion.',
1614: 'chgt' => 'Change to '
1615: );
1616: my $dispchange = $lt{'unread'};
1617: my $markchange = $lt{'ondisp'};
1618: my $currdisp = $lt{'allposts'};
1619: my $currmark = $lt{'onmark'};
1620:
1621: if ($discdisp eq 'unread') {
1622: $dispchange = $lt{'allposts'};
1623: $currdisp = $lt{'unread'};
1624: $newdisp = 'allposts';
1625: }
1626:
1627: if ($discmark eq 'ondisp') {
1628: $markchange = $lt{'onmark'};
1629: $currmark = $lt{'ondisp'};
1630: $newmark = 'onmark';
1.42 raeburn 1631: }
1.43 raeburn 1632:
1633: $r->print(<<"END");
1.88 albertel 1634: <form name="prefs" action="/adm/preferences" method="post">
1.42 raeburn 1635: <input type="hidden" name="action" value="verify_and_change_discussion" />
1636: <br />
1.87 albertel 1637: $lt{'sdpf'}<br /> $lt{'prca'} <ol><li>$lt{'whpo'}</li><li>$lt{'unwh'}</li></ol>
1.43 raeburn 1638: <br />
1639: <br />
1.82 albertel 1640: END
1641: $r->print(&Apache::loncommon::start_data_table());
1642: $r->print(<<"END");
1643: <tr>
1644: <th>$lt{'pref'}</th>
1645: <th>$lt{'curr'}</th>
1646: <th>$lt{'actn'}?</th>
1.43 raeburn 1647: </tr>
1.82 albertel 1648: END
1649: $r->print(&Apache::loncommon::start_data_table_row());
1650: $r->print(<<"END");
1.43 raeburn 1651: <td>$lt{'disa'}</td>
1652: <td>$lt{$discdisp}</td>
1.82 albertel 1653: <td><label><input type="checkbox" name="discdisp" /><input type="hidden" name="newdisp" value="$newdisp" /> $lt{'chgt'} "$dispchange"</label></td>
1654: END
1655: $r->print(&Apache::loncommon::end_data_table_row().
1656: &Apache::loncommon::start_data_table_row());
1657: $r->print(<<"END");
1.43 raeburn 1658: <td>$lt{'npmr'}</td>
1659: <td>$lt{$discmark}</td>
1.82 albertel 1660: <td><label><input type="checkbox" name="discmark" /><input type="hidden" name="newmark" value="$newmark" /> $lt{'chgt'} "$markchange"</label></td>
1.43 raeburn 1661: </tr>
1.82 albertel 1662: END
1663: $r->print(&Apache::loncommon::end_data_table_row().
1664: &Apache::loncommon::end_data_table());
1.142 zhu 1665:
1666: $r->print('<br /><br /><input type="submit" name="sub" value="'.&mt('Save').'" /><br /><br />'.&mt('Note').': '.$lt{'thde'}.'</form>');
1.42 raeburn 1667: }
1668:
1669: sub verify_and_change_discussion {
1670: my $r = shift;
1.59 albertel 1671: my $user = $env{'user.name'};
1672: my $domain = $env{'user.domain'};
1.42 raeburn 1673: my $message='';
1.59 albertel 1674: if (defined($env{'form.discdisp'}) ) {
1675: my $newdisp = $env{'form.newdisp'};
1.43 raeburn 1676: if ($newdisp eq 'unread') {
1.110 bisitz 1677: $message .=&mt('In discussions: only new posts will be displayed.').'<br />';
1.43 raeburn 1678: &Apache::lonnet::put('environment',{'discdisplay' => $newdisp});
1.116 raeburn 1679: &Apache::lonnet::appenv({'environment.discdisplay' => $newdisp});
1.43 raeburn 1680: } else {
1.110 bisitz 1681: $message .= &mt('In discussions: all posts will be displayed.').'<br />';
1.43 raeburn 1682: &Apache::lonnet::del('environment',['discdisplay']);
1.139 raeburn 1683: &Apache::lonnet::delenv('environment.discdisplay');
1.43 raeburn 1684: }
1685: }
1.59 albertel 1686: if (defined($env{'form.discmark'}) ) {
1687: my $newmark = $env{'form.newmark'};
1.43 raeburn 1688: if ($newmark eq 'ondisp') {
1.152 www 1689: $message.=&Apache::lonhtmlcommon::confirm_success(&mt('In discussions: new posts will be cease to be identified as "NEW" after display.')).'<br />';
1.43 raeburn 1690: &Apache::lonnet::put('environment',{'discmarkread' => $newmark});
1.116 raeburn 1691: &Apache::lonnet::appenv({'environment.discmarkread' => $newmark});
1.43 raeburn 1692: } else {
1.152 www 1693: $message.=&Apache::lonhtmlcommon::confirm_success(&mt('In discussions: posts will be identified as "NEW" until marked as read by the reader.')).'<br />';
1.43 raeburn 1694: &Apache::lonnet::del('environment',['discmarkread']);
1.139 raeburn 1695: &Apache::lonnet::delenv('environment.discmarkread');
1.43 raeburn 1696: }
1.42 raeburn 1697: }
1.152 www 1698: &print_main_menu($r, $message);
1.42 raeburn 1699: }
1700:
1.63 raeburn 1701: ################################################################
1702: # Subroutines for page display on course access (Course Coordinators)
1703: ################################################################
1704: sub coursedisplaychanger {
1705: my $r = shift;
1.152 www 1706: &Apache::lonhtmlcommon::add_breadcrumb(
1.126 droeschl 1707: { href => '/adm/preferences?action=changecourseinit',
1708: text => 'Change Course Init. Pref.'});
1709: $r->print(Apache::loncommon::start_page('Change Course Initialization Preference'));
1710: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Course Init. Pref.'));
1.63 raeburn 1711: my $user = $env{'user.name'};
1712: my $domain = $env{'user.domain'};
1.66 albertel 1713: my %userenv = &Apache::lonnet::get('environment',['course_init_display']);
1.71 raeburn 1714: my $currvalue = 'whatsnew';
1.73 albertel 1715: my $firstselect = '';
1716: my $whatsnewselect = 'checked="checked"';
1.71 raeburn 1717: if (exists($userenv{'course_init_display'})) {
1718: if ($userenv{'course_init_display'} eq 'firstres') {
1719: $currvalue = 'firstres';
1.73 albertel 1720: $firstselect = 'checked="checked"';
1721: $whatsnewselect = '';
1.71 raeburn 1722: }
1.63 raeburn 1723: }
1.134 bisitz 1724: my %pagenames = &Apache::lonlocal::texthash(
1.71 raeburn 1725: firstres => 'First resource',
1.143 hauer 1726: whatsnew => "What's New Page",
1.71 raeburn 1727: );
1.134 bisitz 1728: my $whatsnew_off=&mt('Display the [_1]first resource[_2] in the course.','<b>','</b>');
1.143 hauer 1729: my $whatsnew_on=&mt("Display the [_1]What's New Page[_2] - a summary of items in the course which require attention.",'<b>','</b>');
1.63 raeburn 1730:
1.134 bisitz 1731: $r->print('<br /><b>'
1732: .&mt('Set the default page to be displayed when you select a course role')
1733: .'</b> '
1734: .&mt('(Currently: [_1])',$pagenames{$currvalue})
1735: .'<br />'
1.143 hauer 1736: .&mt("The global user preference you set for your courses can be overridden in an individual course by setting a course specific setting via the [_1]What's New Page[_2] in the course.",'<i>','</i>')
1.134 bisitz 1737: .'<br /><br />'
1738: );
1.63 raeburn 1739: $r->print(<<ENDLSCREEN);
1.88 albertel 1740: <form name="prefs" action="/adm/preferences" method="post">
1.63 raeburn 1741: <input type="hidden" name="action" value="verify_and_change_coursepage" />
1.72 albertel 1742: <br />
1.65 albertel 1743: <label><input type="radio" name="newdisp" value="firstres" $firstselect /> $whatsnew_off</label><br />
1.70 raeburn 1744: <label><input type="radio" name="newdisp" value="whatsnew" $whatsnewselect /> $whatsnew_on</label><input type="hidden" name="refpage" value="$env{'form.refpage'}" />
1.63 raeburn 1745: ENDLSCREEN
1.140 schafran 1746: $r->print('<br /><br /><input type="submit" value="'.&mt('Save').'" />
1.63 raeburn 1747: </form>');
1748: }
1749:
1750: sub verify_and_change_coursepage {
1751: my $r = shift;
1752: my $message='';
1753: my %lt = &Apache::lonlocal::texthash(
1.70 raeburn 1754: 'defs' => 'Default now set',
1.71 raeburn 1755: 'when' => 'when you select a course role from the roles screen',
1.63 raeburn 1756: 'ywbt' => 'you will be taken to the start of the course.',
1757: 'apwb' => 'a page will be displayed that lists items in the course that may require action from you.',
1758: 'gtts' => 'Go to the start of the course',
1.146 hauer 1759: 'dasp' => "Display the What's New Page",
1.63 raeburn 1760: );
1761: my $newdisp = $env{'form.newdisp'};
1.70 raeburn 1762: $message = '<b>'.$lt{'defs'}.'</b>: '.$lt{'when'}.', ';
1.63 raeburn 1763: if ($newdisp eq 'firstres') {
1.87 albertel 1764: $message .= $lt{'ywbt'}.'<br />';
1.63 raeburn 1765: &Apache::lonnet::put('environment',{'course_init_display' => $newdisp});
1.116 raeburn 1766: &Apache::lonnet::appenv({'environment.course_init_display' => $newdisp});
1.63 raeburn 1767: } else {
1.87 albertel 1768: $message .= $lt{'apwb'}.'<br />';
1.63 raeburn 1769: &Apache::lonnet::del('environment',['course_init_display']);
1.139 raeburn 1770: &Apache::lonnet::delenv('environment.course_init_display');
1.63 raeburn 1771: }
1.70 raeburn 1772: my $refpage = $env{'form.refpage'};
1.63 raeburn 1773: if (($env{'request.course.fn'}) && ($env{'request.course.id'})) {
1774: if ($newdisp eq 'firstres') {
1775: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
1776: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
1777: my ($furl,$ferr)=
1778: &Apache::lonuserstate::readmap($cdom.'/'.$cnum);
1779: $message .= '<br /><font size="+1"><a href="'.$furl.'">'.$lt{'gtts'}.' <i>'.&mt('now').'</i></a></font>';
1780: } else {
1.70 raeburn 1781: $message .= '<br /><font size="+1"><a href="/adm/whatsnew?refpage='.
1782: $refpage.'">'.$lt{'dasp'}.'</a></font>';
1.63 raeburn 1783: }
1784: }
1.152 www 1785: &print_main_menu($r, &Apache::lonhtmlcommon::confirm_success($message));
1.63 raeburn 1786: }
1787:
1.126 droeschl 1788: sub print_main_menu {
1789: my ($r, $message) = @_;
1790: # Determine current authentication method
1791: my $user = $env{'user.name'};
1792: my $domain = $env{'user.domain'};
1793: my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
1794:
1795: # build the data structure for menu generation
1796: my $aboutmeurl='/adm/'.$env{'user.domain'}.'/'.$env{'user.name'}.'/aboutme';
1797: my $role = ($env{'user.adv'} ? 'Roles' : 'Course');
1.131 raeburn 1798: my %permissions;
1799: if (&Apache::lonnet::usertools_access($user,$domain,'aboutme')) {
1800: $permissions{'aboutme'} = 'F';
1801: }
1.126 droeschl 1802: my @menu=
1803: ({ categorytitle=>'Personal Data',
1804: items =>[
1.141 weissno 1805: { linktext => 'Personal Information Page',
1.126 droeschl 1806: url => $aboutmeurl,
1.131 raeburn 1807: permission => $permissions{'aboutme'},
1.126 droeschl 1808: #help => 'Prefs_About_Me',
1809: icon => 'system-users.png',
1810: linktitle => 'Edit information about yourself that should be displayed on your public profile.'
1811: },
1812: { linktext => 'Screen Name',
1813: url => '/adm/preferences?action=changescreenname',
1814: permission => 'F',
1815: #help => 'Prefs_Screen_Name_Nickname',
1816: icon => 'preferences-desktop-font.png',
1817: linktitle => 'Change the name that is displayed in your posts.'
1818: },
1819: ]
1820: },
1821: { categorytitle=>'Page Display Settings',
1822: items =>[
1823: { linktext => 'Color Scheme',
1824: url => '/adm/preferences?action=changecolors',
1825: permission => 'F',
1826: #help => 'Change_Colors',
1827: icon => 'preferences-desktop-theme.png',
1828: linktitle => 'Change LON-CAPA default colors.'
1829: },
1830: { linktext => 'Menu Display',
1831: url => '/adm/preferences?action=changeicons',
1832: permission => 'F',
1833: #help => '',
1834: icon => 'preferences-system-windows.png',
1835: linktitle => 'Change whether the menus are displayed with buttons, icons or icons and text.'
1836: }
1837:
1838: ]
1839: },
1840: { categorytitle=>'Content Display Settings',
1841: items =>[
1842: { linktext => 'Language',
1843: url => '/adm/preferences?action=changelanguages',
1844: permission => 'F',
1845: #help => 'Prefs_Language',
1846: icon => 'preferences-desktop-locale.png',
1.127 droeschl 1847: linktitle => 'Choose the default language for this user.'
1.126 droeschl 1848: },
1.128 droeschl 1849: { linktext => 'WYSIWYG Editor',
1.126 droeschl 1850: url => '/adm/preferences?action=changewysiwyg',
1851: permission => 'F',
1852: #help => '',
1853: icon => 'edit-select-all.png',
1854: linktitle => 'Enable or disable the WYSIWYG-Editor.'
1855: },
1.128 droeschl 1856: { linktext => $role.' Page',
1.126 droeschl 1857: url => '/adm/preferences?action=changerolespref',
1858: permission => 'F',
1859: #help => '',
1860: icon => 'sctr.png',
1861: linktitle => 'Configure the roles hotlist.'
1862: },
1.127 droeschl 1863: { linktext => 'Display of Scientific Equations',
1.126 droeschl 1864: url => '/adm/preferences?action=changetexenginepref',
1865: permission => 'F',
1866: #help => '',
1867: icon => 'stat.png',
1.127 droeschl 1868: linktitle => 'Change how Scientific Equations are displayed.'
1.126 droeschl 1869: },
1870: ]
1871: },
1.128 droeschl 1872: { categorytitle=>'Message Management',
1873: items =>[
1.153 www 1874: { linktext => 'Messages & Notifications',
1.128 droeschl 1875: url => '/adm/preferences?action=changemsgforward',
1876: permission => 'F',
1877: #help => 'Prefs_Messages',
1878: icon => 'mail-reply-all.png',
1879: linktitle => 'Change messageforwarding or notifications settings.'
1880: },
1881: { linktext => 'Discussion Display',
1882: url => '/adm/preferences?action=changediscussions',
1883: permission => 'F',
1884: #help => 'Change_Discussion_Display',
1885: icon => 'mail-message-new.png',
1.135 schafran 1886: linktitle => 'Set display preferences for discussion posts for both discussion boards and individual resources in all your courses.'
1.128 droeschl 1887: },
1888: ]
1889: },
1.126 droeschl 1890: { categorytitle=>'Other',
1891: items =>[
1.153 www 1892: { linktext => 'Register Response Devices ("Clickers")',
1.126 droeschl 1893: url => '/adm/preferences?action=changeclicker',
1894: permission => 'F',
1895: #help => '',
1896: icon => 'network-workgroup.png',
1897: linktitle => 'Register your clicker.'
1898: },
1899: ]
1900: },
1901: );
1902:
1903: if ($currentauth =~ /^(unix|internal):/) {
1904: push(@{ $menu[0]->{items} }, {
1905: linktext => 'Password',
1906: url => '/adm/preferences?action=changepass',
1907: permission => 'F',
1908: #help => 'Change_Password',
1909: icon => 'emblem-readonly.png',
1910: linktitle => 'Change your password.',
1911: });
1912: }
1913: if ($env{'environment.remote'} eq 'off') {
1914: push(@{ $menu[1]->{items} }, {
1915: linktext => 'Launch Remote Control',
1916: url => '/adm/remote?url=/adm/preferences?action=launch',
1917: permission => 'F',
1918: #help => '',
1919: icon => 'network-wireless.png',
1920: linktitle => 'Launch the remote control for LON-CAPA.',
1921: });
1922: }else{
1923: push(@{ $menu[1]->{items} }, {
1924: linktext => 'Collapse Remote Control',
1925: url => '/adm/remote?url=/adm/preferences?action=collapse',
1926: permission => 'F',
1927: #help => '',
1928: icon => 'network-wireless.png',
1929: linktitle => 'Collapse the remote control for LON-CAPA.',
1930: });
1931: }
1932: my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au']);
1933: if (keys(%author_roles) > 0) {
1934: push(@{ $menu[4]->{items} }, {
1935: linktext => 'Restrict Domain Coordinator Access',
1936: url => '/adm/preferences?action=changedomcoord',
1937: permission => 'F',
1938: #help => '',
1939: icon => 'system-lock-screen.png',
1940: linktitle => 'Restrict domain coordinator access.',
1941: });
1942: }
1943:
1944: if (&Apache::lonnet::allowed('whn',$env{'request.course.id'})
1945: || &Apache::lonnet::allowed('whn',$env{'request.course.id'}.'/'
1946: .$env{'request.course.sec'})) {
1947: push(@{ $menu[4]->{items} }, {
1.128 droeschl 1948: linktext => 'Course Initialization',
1.126 droeschl 1949: url => '/adm/preferences?action=changecourseinit',
1950: permission => 'F',
1951: #help => '',
1952: icon => 'edit-copy.png',
1953: linktitle => 'Set the default page to be displayed when you select a course role.',
1954: });
1955:
1956: }
1957: if ($env{'user.name'} =~ /^(albertel|fox|foxr|kortemey|korte|raeburn)$/) {
1958: push(@{ $menu[4]->{items} }, {
1959: linktext => 'Toggle Debug Messages (Current:'.$env{'user.debug'}.')',
1960: url => '/adm/preferences?action=debugtoggle',
1961: permission => 'F',
1962: #help => '',
1963: icon => 'blog.png',
1964: linktitle => 'Toggle Debug Messages.',
1965: });
1966: }
1967:
1.147 schafran 1968: $r->print(&Apache::loncommon::start_page('My Space'));
1.126 droeschl 1969: $r->print(Apache::lonhtmlcommon::breadcrumbs('Change Preferences'));
1970: $r->print($message);
1971: $r->print(Apache::lonhtmlcommon::generate_menu(@menu));
1972: $r->print(Apache::loncommon::end_page());
1973: }
1.63 raeburn 1974:
1.4 matthew 1975: ######################################################
1976: # other handler subroutines #
1977: ######################################################
1978:
1.3 matthew 1979: ################################################################
1980: # Main handler #
1981: ################################################################
1.126 droeschl 1982: sub handler {
1983: my $r = shift;
1984: Apache::loncommon::content_type($r,'text/html');
1985: # Some pages contain DES keys and should not be cached.
1986: Apache::loncommon::no_cache($r);
1987: $r->send_http_header;
1988: return OK if $r->header_only;
1989: #
1990: Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1991: ['action','wysiwyg','returnurl','refpage']);
1992: #
1993: Apache::lonhtmlcommon::clear_breadcrumbs();
1994: Apache::lonhtmlcommon::add_breadcrumb
1995: ({href => '/adm/preferences',
1.150 droeschl 1996: text => 'Set User Preferences',
1997: help =>
1998: 'Prefs_About_Me,Prefs_Language,Prefs_Screen_Name_Nickname,Change_Colors,Change_Password,Prefs_Messages,Change_Discussion_Display'});
1.126 droeschl 1999: if(!exists $env{'form.action'}) {
1.150 droeschl 2000: &print_main_menu($r);
1.126 droeschl 2001: }elsif($env{'form.action'} eq 'changepass'){
2002: &passwordchanger($r);
2003: }elsif($env{'form.action'} eq 'verify_and_change_pass'){
2004: &verify_and_change_password($r);
2005: }elsif($env{'form.action'} eq 'changescreenname'){
2006: &screennamechanger($r);
2007: }elsif($env{'form.action'} eq 'verify_and_change_screenname'){
2008: &verify_and_change_screenname($r);
2009: }elsif($env{'form.action'} eq 'changemsgforward'){
2010: &msgforwardchanger($r);
2011: }elsif($env{'form.action'} eq 'verify_and_change_msgforward'){
2012: &verify_and_change_msgforward($r);
2013: }elsif($env{'form.action'} eq 'changecolors'){
2014: &colorschanger($r);
2015: }elsif($env{'form.action'} eq 'verify_and_change_colors'){
2016: &verify_and_change_colors($r);
2017: }elsif($env{'form.action'} eq 'changelanguages'){
2018: &languagechanger($r);
2019: }elsif($env{'form.action'} eq 'verify_and_change_languages'){
2020: &verify_and_change_languages($r);
2021: }elsif($env{'form.action'} eq 'changewysiwyg'){
2022: &wysiwygchanger($r);
2023: }elsif($env{'form.action'} eq 'set_wysiwyg'){
2024: &verify_and_change_wysiwyg($r);
2025: }elsif($env{'form.action'} eq 'changediscussions'){
2026: &discussionchanger($r);
2027: }elsif($env{'form.action'} eq 'verify_and_change_discussion'){
2028: &verify_and_change_discussion($r);
2029: }elsif($env{'form.action'} eq 'changerolespref'){
2030: &rolesprefchanger($r);
2031: }elsif($env{'form.action'} eq 'verify_and_change_rolespref'){
2032: &verify_and_change_rolespref($r);
2033: }elsif($env{'form.action'} eq 'changetexenginepref'){
2034: &texenginechanger($r);
2035: }elsif($env{'form.action'} eq 'verify_and_change_texengine'){
2036: &verify_and_change_texengine($r);
2037: }elsif($env{'form.action'} eq 'changeicons'){
2038: &iconchanger($r);
2039: }elsif($env{'form.action'} eq 'verify_and_change_icons'){
2040: &verify_and_change_icons($r);
2041: }elsif($env{'form.action'} eq 'changeclicker'){
2042: &clickerchanger($r);
2043: }elsif($env{'form.action'} eq 'verify_and_change_clicker'){
2044: &verify_and_change_clicker($r);
2045: }elsif($env{'form.action'} eq 'changedomcoord'){
2046: &domcoordchanger($r);
2047: }elsif($env{'form.action'} eq 'verify_and_change_domcoord'){
2048: &verify_and_change_domcoord($r);
2049: }elsif($env{'form.action'} eq 'lockwarning'){
2050: &lockwarning($r);
2051: }elsif($env{'form.action'} eq 'verify_and_change_locks'){
2052: &verify_and_change_lockwarning($r);
2053: }elsif($env{'form.action'} eq 'changecourseinit'){
2054: &coursedisplaychanger($r);
2055: }elsif($env{'form.action'} eq 'verify_and_change_coursepage'){
2056: &verify_and_change_coursepage($r);
2057: }elsif($env{'form.action'} eq 'debugtoggle'){
1.154 www 2058: &toggle_debug();
2059: &print_main_menu($r);
1.126 droeschl 2060: }
2061:
2062: return OK;
2063:
2064:
2065: }
2066: #remove when done
2067: #old handler routine
2068: sub handler2 {
1.1 www 2069: my $r = shift;
1.59 albertel 2070: my $user = $env{'user.name'};
2071: my $domain = $env{'user.domain'};
1.31 www 2072: &Apache::loncommon::content_type($r,'text/html');
1.4 matthew 2073: # Some pages contain DES keys and should not be cached.
2074: &Apache::loncommon::no_cache($r);
1.1 www 2075: $r->send_http_header;
2076: return OK if $r->header_only;
1.9 matthew 2077: #
1.35 matthew 2078: &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
1.70 raeburn 2079: ['action','wysiwyg','returnurl','refpage']);
1.35 matthew 2080: #
2081: &Apache::lonhtmlcommon::clear_breadcrumbs();
2082: &Apache::lonhtmlcommon::add_breadcrumb
2083: ({href => '/adm/preferences',
2084: text => 'Set User Preferences'});
2085:
2086: my @Options;
2087: # Determine current authentication method
2088: my $currentauth=&Apache::lonnet::queryauthenticate($user,$domain);
2089: if ($currentauth =~ /^(unix|internal):/) {
2090: push (@Options,({ action => 'changepass',
1.40 www 2091: linktext => 'Change Password',
1.35 matthew 2092: href => '/adm/preferences',
2093: help => 'Change_Password',
2094: subroutine => \&passwordchanger,
2095: breadcrumb =>
2096: { href => '/adm/preferences?action=changepass',
2097: text => 'Change Password'},
2098: },
2099: { action => 'verify_and_change_pass',
2100: subroutine => \&verify_and_change_password,
2101: breadcrumb =>
2102: { href =>'/adm/preferences?action=changepass',
2103: text => 'Change Password'},
1.75 albertel 2104: printmenu => 'not_on_error',
1.35 matthew 2105: }));
2106: }
2107: push (@Options,({ action => 'changescreenname',
2108: linktext => 'Change Screen Name',
2109: href => '/adm/preferences',
2110: help => 'Prefs_Screen_Name_Nickname',
2111: subroutine => \&screennamechanger,
2112: breadcrumb =>
2113: { href => '/adm/preferences?action=changescreenname',
2114: text => 'Change Screen Name'},
2115: },
2116: { action => 'verify_and_change_screenname',
2117: subroutine => \&verify_and_change_screenname,
2118: breadcrumb =>
2119: { href => '/adm/preferences?action=changescreenname',
2120: text => 'Change Screen Name'},
2121: printmenu => 'yes',
2122: }));
2123:
2124: push (@Options,({ action => 'changemsgforward',
1.129 schafran 2125: linktext => 'Change Message Forwarding and Notification E-mail Addresses',
1.35 matthew 2126: href => '/adm/preferences',
1.113 raeburn 2127: help => 'Prefs_Messages',
1.35 matthew 2128: breadcrumb =>
2129: { href => '/adm/preferences?action=changemsgforward',
1.113 raeburn 2130: text => 'Change Message Forwarding/Notification'},
1.35 matthew 2131: subroutine => \&msgforwardchanger,
2132: },
2133: { action => 'verify_and_change_msgforward',
1.113 raeburn 2134: help => 'Prefs_Messages',
1.35 matthew 2135: breadcrumb =>
2136: { href => '/adm/preferences?action=changemsgforward',
1.113 raeburn 2137: text => 'Change Message Forwarding/Notification'},
1.126 droeschl 2138: printmenu => 'yes',
1.35 matthew 2139: subroutine => \&verify_and_change_msgforward }));
2140: my $aboutmeaction=
1.59 albertel 2141: '/adm/'.$env{'user.domain'}.'/'.$env{'user.name'}.'/aboutme';
1.35 matthew 2142: push (@Options,{ action => 'none',
2143: linktext =>
1.141 weissno 2144: q{Edit the Personal Information Page},
1.45 www 2145: help => 'Prefs_About_Me',
1.35 matthew 2146: href => $aboutmeaction});
2147: push (@Options,({ action => 'changecolors',
2148: linktext => 'Change Color Scheme',
2149: href => '/adm/preferences',
2150: help => 'Change_Colors',
2151: breadcrumb =>
2152: { href => '/adm/preferences?action=changecolors',
2153: text => 'Change Colors'},
2154: subroutine => \&colorschanger,
2155: },
2156: { action => 'verify_and_change_colors',
2157: breadcrumb =>
2158: { href => '/adm/preferences?action=changecolors',
2159: text => 'Change Colors'},
2160: printmenu => 'yes',
2161: subroutine => \&verify_and_change_colors,
2162: }));
2163: push (@Options,({ action => 'changelanguages',
1.39 www 2164: linktext => 'Change Language Preferences',
1.35 matthew 2165: href => '/adm/preferences',
1.45 www 2166: help => 'Prefs_Language',
1.35 matthew 2167: breadcrumb=>
2168: { href => '/adm/preferences?action=changelanguages',
2169: text => 'Change Language'},
2170: subroutine => \&languagechanger,
2171: },
2172: { action => 'verify_and_change_languages',
2173: breadcrumb=>
2174: {href => '/adm/preferences?action=changelanguages',
2175: text => 'Change Language'},
2176: printmenu => 'yes',
2177: subroutine=>\&verify_and_change_languages, }
2178: ));
1.44 www 2179: push (@Options,({ action => 'changewysiwyg',
2180: linktext => 'Change WYSIWYG Editor Preferences',
2181: href => '/adm/preferences',
2182: breadcrumb =>
2183: { href => '/adm/preferences?action=changewysiwyg',
2184: text => 'Change WYSIWYG Preferences'},
2185: subroutine => \&wysiwygchanger,
2186: },
2187: { action => 'set_wysiwyg',
2188: breadcrumb =>
2189: { href => '/adm/preferences?action=changewysiwyg',
2190: text => 'Change WYSIWYG Preferences'},
2191: printmenu => 'yes',
2192: subroutine => \&verify_and_change_wysiwyg, }
2193: ));
1.42 raeburn 2194: push (@Options,({ action => 'changediscussions',
2195: linktext => 'Change Discussion Display Preferences',
2196: href => '/adm/preferences',
1.46 raeburn 2197: help => 'Change_Discussion_Display',
1.42 raeburn 2198: breadcrumb =>
2199: { href => '/adm/preferences?action=changediscussions',
1.43 raeburn 2200: text => 'Change Discussion Preferences'},
1.42 raeburn 2201: subroutine => \&discussionchanger,
2202: },
2203: { action => 'verify_and_change_discussion',
2204: breadcrumb =>
2205: { href => '/adm/preferences?action=changediscussions',
1.43 raeburn 2206: text => 'Change Discussion Preferences'},
1.42 raeburn 2207: printmenu => 'yes',
2208: subroutine => \&verify_and_change_discussion, }
2209: ));
1.96 albertel 2210:
2211: my $role = ($env{'user.adv'} ? 'Roles' : 'Course');
1.50 albertel 2212: push (@Options,({ action => 'changerolespref',
1.96 albertel 2213: linktext => 'Change '.$role.' Page Preferences',
1.50 albertel 2214: href => '/adm/preferences',
2215: subroutine => \&rolesprefchanger,
2216: breadcrumb =>
2217: { href => '/adm/preferences?action=changerolespref',
1.96 albertel 2218: text => 'Change '.$role.' Page Pref'},
1.50 albertel 2219: },
2220: { action => 'verify_and_change_rolespref',
2221: subroutine => \&verify_and_change_rolespref,
2222: breadcrumb =>
2223: { href => '/adm/preferences?action=changerolespref',
1.96 albertel 2224: text => 'Change '.$role.' Page Preferences'},
1.50 albertel 2225: printmenu => 'yes',
2226: }));
2227:
1.54 albertel 2228: push (@Options,({ action => 'changetexenginepref',
2229: linktext => 'Change How Math Equations Are Displayed',
2230: href => '/adm/preferences',
2231: subroutine => \&texenginechanger,
2232: breadcrumb =>
2233: { href => '/adm/preferences?action=changetexenginepref',
2234: text => 'Change Math Pref'},
2235: },
2236: { action => 'verify_and_change_texengine',
2237: subroutine => \&verify_and_change_texengine,
2238: breadcrumb =>
2239: { href => '/adm/preferences?action=changetexenginepref',
2240: text => 'Change Math Preferences'},
2241: printmenu => 'yes',
2242: }));
1.85 albertel 2243:
2244: if ($env{'environment.remote'} eq 'off') {
2245: push (@Options,({ action => 'launch',
2246: linktext => 'Launch Remote Control',
2247: href => '/adm/remote?url=/adm/preferences',
2248: }));
2249: } else {
2250: push (@Options,({ action => 'collapse',
2251: linktext => 'Collapse Remote Control',
2252: href => '/adm/remote?url=/adm/preferences',
2253: }));
2254: }
2255:
1.98 www 2256: push (@Options,({ action => 'changeicons',
1.100 www 2257: linktext => 'Change How Menus are Displayed',
1.98 www 2258: href => '/adm/preferences',
2259: subroutine => \&iconchanger,
2260: breadcrumb =>
2261: { href => '/adm/preferences?action=changeicons',
2262: text => 'Change Main Menu'},
2263: },
2264: { action => 'verify_and_change_icons',
2265: subroutine => \&verify_and_change_icons,
2266: breadcrumb =>
2267: { href => '/adm/preferences?action=changeicons',
2268: text => 'Change Main Menu'},
2269: printmenu => 'yes',
2270: }));
2271:
1.106 www 2272: push (@Options,({ action => 'changeclicker',
2273: linktext => 'Register Response Devices ("Clickers")',
2274: href => '/adm/preferences',
2275: subroutine => \&clickerchanger,
2276: breadcrumb =>
1.118 www 2277: { href => '/adm/preferences?action=changeclicker',
1.106 www 2278: text => 'Register Clicker'},
2279: },
2280: { action => 'verify_and_change_clicker',
2281: subroutine => \&verify_and_change_clicker,
2282: breadcrumb =>
2283: { href => '/adm/preferences?action=changeclicker',
2284: text => 'Register Clicker'},
2285: printmenu => 'yes',
2286: }));
1.125 raeburn 2287: my %author_roles = &Apache::lonnet::get_my_roles($user,$domain,'userroles','',['au']);
2288: if (keys(%author_roles) > 0) {
1.119 www 2289: push (@Options,({ action => 'changedomcoord',
2290: linktext => 'Restrict Domain Coordinator Access',
2291: href => '/adm/preferences',
2292: subroutine => \&domcoordchanger,
2293: breadcrumb =>
2294: { href => '/adm/preferences?action=changedomcoord',
2295: text => 'Restrict Domain Coordinator Access'},
2296: },
2297: { action => 'verify_and_change_domcoord',
2298: subroutine => \&verify_and_change_domcoord,
2299: breadcrumb =>
2300: { href => '/adm/preferences?action=changedomcoord',
2301: text => 'Restrict Domain Coordinator Access'},
2302: printmenu => 'yes',
2303: }));
2304: }
1.105 www 2305:
1.118 www 2306: push (@Options,({ action => 'lockwarning',
2307: subroutine => \&lockwarning,
2308: breadcrumb =>
2309: { href => '/adm/preferences?action=lockwarning',
2310: text => 'Lock Warnings'},
2311: },
2312: { action => 'verify_and_change_locks',
2313: subroutine => \&verify_and_change_lockwarning,
2314: breadcrumb =>
2315: { href => '/adm/preferences?action=lockwarning',
2316: text => 'Lockwarnings'},
2317: printmenu => 'yes',
2318: }));
2319:
1.105 www 2320:
1.74 albertel 2321: if (&Apache::lonnet::allowed('whn',$env{'request.course.id'})
2322: || &Apache::lonnet::allowed('whn',$env{'request.course.id'}.'/'
2323: .$env{'request.course.sec'})) {
1.63 raeburn 2324: push (@Options,({ action => 'changecourseinit',
2325: linktext => 'Change Course Initialization Preference',
2326: href => '/adm/preferences',
2327: subroutine => \&coursedisplaychanger,
2328: breadcrumb =>
2329: { href => '/adm/preferences?action=changecourseinit',
2330: text => 'Change Course Init. Pref.'},
2331: },
2332: { action => 'verify_and_change_coursepage',
2333: breadcrumb =>
2334: { href => '/adm/preferences?action=changecourseinit', text => 'Change Course Initialization Preference'},
2335: printmenu => 'yes',
2336: subroutine => \&verify_and_change_coursepage,
2337: }));
2338: }
1.50 albertel 2339:
1.154 www 2340: if (($env{'user.name'} =~ /^(albertel|fox|foxr|kortemey|korte|raeburn)$/)
2341: && ($env{'user.domain'} =~/^(msu|gerd)$/)){
1.35 matthew 2342: push (@Options,({ action => 'debugtoggle',
2343: printmenu => 'yes',
2344: subroutine => \&toggle_debug,
2345: }));
2346: }
1.76 albertel 2347:
2348: $r->print(&Apache::loncommon::start_page('Change Preferences'));
2349:
1.35 matthew 2350: my $call = undef;
1.48 albertel 2351: my $help = undef;
1.35 matthew 2352: my $printmenu = 'yes';
2353: foreach my $option (@Options) {
1.59 albertel 2354: if ($option->{'action'} eq $env{'form.action'}) {
1.35 matthew 2355: $call = $option->{'subroutine'};
2356: $printmenu = $option->{'printmenu'};
2357: if (exists($option->{'breadcrumb'})) {
2358: &Apache::lonhtmlcommon::add_breadcrumb
2359: ($option->{'breadcrumb'});
2360: }
1.48 albertel 2361: $help=$option->{'help'};
1.35 matthew 2362: }
2363: }
1.81 albertel 2364: $r->print(&Apache::lonhtmlcommon::breadcrumbs('Change Preferences',$help));
1.75 albertel 2365: my $error;
1.35 matthew 2366: if (defined($call)) {
1.75 albertel 2367: $error = $call->($r);
1.35 matthew 2368: }
1.75 albertel 2369: if ( ( ($printmenu eq 'yes')
2370: || ($printmenu eq 'not_on_error' && !$error) )
2371: && (!$env{'form.returnurl'})) {
1.35 matthew 2372: my $optionlist = '<table cellpadding="5">';
1.59 albertel 2373: if ($env{'user.name'} =~
1.62 raeburn 2374: /^(albertel|kortemey|fox|foxr|korte|hallmat3|turtle|raeburn)$/
1.35 matthew 2375: ) {
2376: push (@Options,({ action => 'debugtoggle',
2377: linktext => 'Toggle Debug Messages',
2378: text => 'Current Debug status is -'.
1.59 albertel 2379: $env{'user.debug'}.'-.',
1.35 matthew 2380: href => '/adm/preferences',
2381: printmenu => 'yes',
2382: subroutine => \&toggle_debug,
2383: }));
2384: }
2385: foreach my $option(@Options) {
2386: my $optiontext = '';
2387: if (exists($option->{'href'})) {
1.85 albertel 2388: $option->{'href_args'}{'action'}=$option->{'action'};
2389: $optiontext .=
2390: '<a href="'.&add_get_param($option->{'href'},
2391: $option->{'href_args'}).'">'.
1.47 albertel 2392: &mt($option->{'linktext'}).'</a>';
1.35 matthew 2393: }
2394: if (exists($option->{'text'})) {
1.47 albertel 2395: $optiontext .= ' '.&mt($option->{'text'});
1.35 matthew 2396: }
2397: if ($optiontext ne '') {
2398: $optiontext = '<font size="+1">'.$optiontext.'</font>';
2399: my $helplink = ' ';
2400: if (exists($option->{'help'})) {
2401: $helplink = &Apache::loncommon::help_open_topic
2402: ($option->{'help'});
2403: }
2404: $optionlist .= '<tr>'.
2405: '<td>'.$helplink.'</td>'.
2406: '<td>'.$optiontext.'</td>'.
2407: '</tr>';
2408: }
1.13 www 2409: }
1.35 matthew 2410: $optionlist .= '</table>';
2411: $r->print($optionlist);
1.59 albertel 2412: } elsif ($env{'form.returnurl'}) {
2413: $r->print('<br /><a href="'.$env{'form.returnurl'}.'"><font size="+1">'.
1.44 www 2414: &mt('Return').'</font></a>');
1.3 matthew 2415: }
1.76 albertel 2416: $r->print(&Apache::loncommon::end_page());
1.1 www 2417: return OK;
1.35 matthew 2418: }
2419:
2420: sub toggle_debug {
1.59 albertel 2421: if ($env{'user.debug'}) {
1.139 raeburn 2422: &Apache::lonnet::delenv('user.debug');
1.35 matthew 2423: } else {
1.116 raeburn 2424: &Apache::lonnet::appenv({'user.debug' => 1});
1.35 matthew 2425: }
1.13 www 2426: }
1.1 www 2427:
2428: 1;
2429: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>