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